Do not open form on click if no records found

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

Guest

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
 
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
 
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?
 
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
 
Back
Top