After Filter if form is blank then close

A

Andi Lee Davis

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
 
N

Nikos Yannacopoulos

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top