Queries that do not return any records - how do i prevent form loa

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I've produced a linked database i use for validation of records entered into
a database that are incomplete (ie. contain blank fields).

I've produced a form linked to the validation query which pulls up the
incomplete records and allows me to delete them.

If there are no incomplete records in the database, i'm getting a blank form
popping up. Can i add some code (in the OnOpen property?) which gives me a
popup box stating "No incomplete records". I can add then add a bit of code
to return me to the main menu.

Any help would be greatly appreciated.

Many thanks,
 
The the On Open property of the form to:
[Event Procedure]
Click the Build button (...) beside this.
Access opens the code window.
Set up the event procedure like this:

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

If you used OpenForm to open the form, in the routine where you did that,
Access will use error 2501 to notify you that the form did not open. Use
error handling in that routine to trap and ignore error number 2501.
 
Back
Top