Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form/querry 1

Status
Not open for further replies.

dan9991

Programmer
Feb 25, 2003
27
GB
I have a form that is bassed on a querry that works fine but when there is no data nothing on the form detail shows up. I don't mind this but would like to run a macro when the data is empty so how do i do this. I know you probably have to use the if function but don't know the exact code. I also don't know where to put it. Cheers.
 
Open the form in Design view, go to View-Code and paste the following lines:


Private Sub Form_Open(Cancel As Integer)
With Me.RecordsetClone
If .EOF And .BOF Then
Cancel = True
MsgBox "No records!"
DoCmd.RunMacro "YourMacroName"
End If
End With
End Sub

But I would suggest that you give up macro usage and switch to VB code, it'll give you the possibility to trap errors and many more...

Good luck
[pipe]
Daniel Vlas
Systems Consultant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top