Form blank

a.sinatra

quik
Local time
Today, 08:02
Joined
Jan 10, 2004
Messages
262
When i call a query from a form, the form is blank cause there is no data stored, is it possible to have something say that there is nothing available, instead of having it blank?
________
Maine dispensary
 
Last edited:
Private Sub Form_Open(Cancel As Integer)

If Me.CurrentRecord < 1 Then
MsgBox "There are no records to display.", vbInformation
DoCmd.Close acForm, Me.Name
End If

End Sub

Dave
 
Dave, does that actually work for you?

I would have thought that the form would close each time as the Form_Open event is triggered before the Form_Load event which puts the RecordSource into the form. Then, if I remember correctly, the Form_Current event is next. Form_Activate's in there somewhere too.

If I click a button I'd check the query count before opening the form:

i.e.

Code:
If DCount("MyField", "MyQuery", "MyField = " & Me.txtCriteria) = 0 Then
    MsgBox "No data to show.", vbInformation
Else
    DoCmd.OpenForm "MyForm"
End If
 
You are right again :rolleyes:

But this seemed to work without the form comming into view:


Private Sub Form_Load()

If Me.RecordsetClone.RecordCount < 1 Then
MsgBox "There are no records to display.", vbInformation
DoCmd.Close acForm, Me.Name
End If

End Sub

This was you dont have to fiddle around with lookup fields and syntaxes

BTW from the Access help file (A2000), yes there was actually something in there :p :

When you first open a form, the following events occur in this order:

Open > Load > Resize > Activate > Current

Dave
 

Users who are viewing this thread

Back
Top Bottom