After Filter if form is blank then close

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

I have a filter written in VBA which looks up customers. However if it returns with no matching recordsa blank form is displayed, but all my objects also dissapear including my command close form button.
How in VB can I write a command to display a message box and then close the form on OK.
Presently you have to go to design view and close it that way.

I've tried many things, even like
If Form_Customers = null Then DoCmd.Close

of course this doesn't work. But I'm getting close

Many thanks,

Andi Lee Davis
 
Andi,

Try something like:

If Me.RecordsetClone.RecordCount = 0 Then
Msgbox "No Records Found"
DoCmd.Close acForm, Me.Name
End If

Note: if the code is not in the form's module, you will have to use an
absolute form reference instead of the Me keyword.

HTH,
Nikos

Andi Lee Davis said:
Hi there,

I have a filter written in VBA which looks up customers. However if it
returns with no matching recordsa blank form is displayed, but all my
objects also dissapear including my command close form button.
 
Back
Top