catching an error opening a form with a query as the recordsource


K

Karen

I have a form that I use as a dialog box. On the form is an OK button with
the following code behind it.
'minimizes the dialog box (can't close it because the viewqc form needs
'to use the code number to do the query).
'displays the production record on the form frmviewprodrec
Forms![frmviewprodrecdialog]!Text0.SetFocus
DoCmd.Minimize
DoCmd.OpenForm "frm prod rec view", acNormal

The form [frm prod rec view] has a query as its recordsource. The query
looks for the values from two textboxes on the dialog box form. Text0 asks
for a Code and Text2 asks for a makedate (makedate is a text field and we
enter a datecode). How do I display an message when the query doesn't find
a match? Currently, the [frm prod rec view] form just opens blank, no
controls display but that's no good since there isn't even a close button to
click on to close it.

Thanks for all of your help in these newsgroups. I've been able to create
this application thanks to you.

Karen
 
Ad

Advertisements

S

Steve Schapel

Karen,

You could try it something like this...

If DCount("*","NameOfYourQuery")>0 Then
Forms![frmviewprodrecdialog]!Text0.SetFocus
DoCmd.Minimize
DoCmd.OpenForm "frm prod rec view", acNormal
Else
MsgBox "There is no matching record"
End If
 

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