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

  • Thread starter Thread starter Karen
  • Start date Start date
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
 
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
 
Back
Top