prevent form from opening

  • Thread starter Thread starter liza
  • Start date Start date
L

liza

how can i prevent my form to open when there is no value
on the underlying query? i have a form where the user
input values w/c will be the basis for the form to open,
but the form keeps on opening even the value entered does
not exist. i used macro to open the form with "Where"
condition, i also tried to put the criteria in the query,
but it seems doesn't work.

any help would be highly appreciated. tia.
 
Put the following line of code at the beginning of your code to open the
form:
On Error Resume Next

Put the following code in the form's Open event:
If Me.RecordsetClone.RecordCount = 0 Then
Cancel = True
Msgbox "There Are No Records In The Underlying Query"
End If
 
thanks a lot! this code works perfect!!!
-----Original Message-----
Put the following line of code at the beginning of your code to open the
form:
On Error Resume Next

Put the following code in the form's Open event:
If Me.RecordsetClone.RecordCount = 0 Then
Cancel = True
Msgbox "There Are No Records In The Underlying Query"
End If

--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
(e-mail address removed)
www.pcdatasheet.com







.
 
Back
Top