Help Please : Displaying Custom Message A2002

M

Mike Wilson

Hi

I have a simple question (to anybody who isn't me)

I am launching a form called Shipping from another form
called Completed with the following link criteria;

Private Sub Shpd_Click()
On Error GoTo Err_Shpd_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Shipping"

stLinkCriteria = "[SOrder_CustRef]=" & "'" & Me![ONo]
& "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Shpd_Click:
Exit Sub

End Sub

If there is no match in the Shipping form, I get a blank
form with no fields, not even an unbound one.

What I want to display is a message box stating that
"No Record is Yet Available"

I would be grateful if someone could point me in the
right direction.


Thank you


Mike
 
S

Sandra Daigle

Hi Mike,

Your form is probably showing up blank because your form is read only and
there is no data returned in the underlying recordset. Here are a couple of
kb articles that describe this problem:

ACC2000: Form Appears Blank When Opened Except for Header
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q209617

ACC2000: Form Opened in Form View Is Completely Blank
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q209734

Here is some simple code you can put into the Open even of the form to avoid
this situation:

Private Sub Form_Open(Cancel As Integer)
Me.Visible = False
If Me.Recordset.EOF And Me.Recordset.BOF Then
MsgBox "There are no records, sorry"
Cancel = True
Else
Me.Visible = True
End If

End Sub

This simply notifies the user that there are no records and closes the form
before it has been made visible.
 
Top