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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cancelling On Close Event if No Data found

Status
Not open for further replies.

Aqif

Programmer
Apr 27, 2002
240
AU
Hi :)

I have got Code behind No Data Event as

Msgbox "No Data"
DoCmd.CancelEvent

I have also got a code behind my On Close event of report as

If Msgbox("Do You want to Insert date",VbYesNo)=VbYes Then
do something-----
end if

The problem is that if no data is found the message gets displayed but still it goes to On Close event and ask to Insert date. Is there any way getting around it?

Cheers!
Aqif
 
Hi Aqif.

How about setting up a Module level variable
Dim bAskForDate As Boolean

Then in the Form Open ( Or Form Load )
bAskForDate = True


Then in the No Data event
Msgbox "No Data"
bAskForDate = False
DoCmd.CancelEvent


And finally in the On Close event

If bAskForDate Then
If Msgbox("Do You want to Insert date",VbYesNo)=VbYes Then
do something-----
end if
End IF




QED?

G LS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top