Prevent opening of a form without no data

sanalsurabhi

New member
Local time
Today, 23:51
Joined
Jan 14, 2010
Messages
7
How to prevent opening of a form which has no data and display a message in this regard in access 2007.
 
in the query that the form uses , ie: qsData
check to see if it has records:

Code:
sub btnOpenFrm_click()
if Dcount("*","qsData")>0 then 
    docmd.OpenForm "fMyForm"
else
    msgbox "No data"
endif

end sub
 
Thank you for the reply. My query has data but no data in respect of a particular "EmpID". I am trying to change your code to suit the situation. Can you help me?
 
How are you passing the EmpID to the form?
 
If EmpID is Numeric

Code:
If DCount("*", "YourQueryName", "EmpID =" & Me.EmpID) > 0 Then

  DoCmd.OpenForm "FormName", , , "EmpID =" & Me.EmpID

Else

  MsgBox "No Matching Record Found!"

End If

If EmpID is Text

Code:
If DCount("*", "YourQueryName", "EmpID ='" & Me.EmpID & "'") > 0 Then

  DoCmd.OpenForm "FormName", , , "EmpID ='" & Me.EmpID & "'"

Else

  MsgBox "No Matching Record Found!"

End If
Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom