bottom with a where condition not fined a match

joeschwa

Registered User.
Local time
Today, 04:35
Joined
Aug 24, 2015
Messages
10
I have a simple bottom to for docnd openform (with VBA) with a where condition
so my question is now! how can put in the code if he is not fined a match in the where condition than he should open a MsgBox saying "don't fined" & exit sub (instar than open the form in a blank new record)
 
Code:
 in the forms open event
 if dcount("*",me.recordsource)=0 then
    msgbox "no records"
    cancel = true
    exit sub
 end if

this will cause a 2501 error in the calling module, that you will need to dismiss

(or you could test the recordcount before trying to open the form)
 
I write the code & noting happened
its still open with a new record
 
Thad is the code

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
Cancel = True
MsgBox "No records"
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom