Do not open form on click if no records found

B

Becky

I have built a login screen using text boxes and a query by form. When the
LOGIN button is clicked another form is opened that contains the information
found in the record. Everything is working beautifully, unless no record is
found. Then the form opens with a blank record. When the "Exit" button is
clicked a new recorded is added to the table with incomplete information.

What I would like to happen is for a check to ensure that a record is found.
If that check fails I do not want the form to open. I would like to insert
a message box at this point that tells the user to enter accurate
information. A Combo or List box will not work for my purposes on the form.

Any help would be greatly appreciated.
Becky
 
P

Paul B.

Becky,

the following was just given to me in an earlier post, I think it will work
for you...put it in the On Click event of your button.


If DCount("*","qryName") Then
DoCmd.OpenForm "frmName"
Else
MsgBox("blah blah....")
End If



Cheers
 
B

Becky

Thanks for the reply.... Becase I am using a Query By Form. My onclick
event contains a macro. Is it possible to put this command in the on open
event of the form that is opening?
 
B

Becky

2nd Response
Well I put the command in the on open event and moved the macro and it works
wonderfully! Thank you so much!

Becky
 

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