Inquiry form with no data

  • Thread starter Sarah at DaVita
  • Start date
S

Sarah at DaVita

How do I check for no data and if there is not canel the opening of the form?
Something like the if no data event on a report?
 
M

Marshall Barton

How do I check for no data and if there is not canel the opening of the form?
Something like the if no data event on a report?


You can use this in the form's Load event:

If Me.RecordsetClone.RecordCount = 0 Then Cancel = True
 
S

Sarah at DaVita

When I do this I get a variable not defined error showing on 'Cancel ='
What am I missing?
 
S

Steve

The recordsource of your form is either a table or a query. Change your
current code that opens the form to look like this:

If DCount("*","NameOfTableOrQuery") <> 0 Then
DoCmd.OpenForm "NameOfForm"
Else
Msgbox "There is No data In The RecordSource Of The Form",,"Sorry No
Data"
End If

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
[email protected]
 
Top