Displaying form when conditions are met

dakcg

Registered User.
Local time
Today, 22:51
Joined
Aug 24, 2001
Messages
88
Greetings,

I have a database that opens with a reminder screen that runs a query to bring up any reminders that are equal or before the current date. That part works perfectly, the problem is, I cannot figure out how to get the form to Not open when there is no reminders that meet the criteria.

Any help is appreciated.

Thanks

Doreen
 
try this
in the on open event for your form


Dim dbs As DAO.Database

Dim Rst As DAO.Recordset
Set dbs = CurrentDb()
Dim QDF As DAO.QueryDef
Dim PRM As Parameter

Set QDF = dbs.QueryDefs("yourqueryName")
For Each PRM In QDF.Parameters
PRM.Value = Eval(PRM.name)
Next PRM
Set Rst = QDF.OpenRecordset(dbOpenDynaset)
With Rst
If Rst.BOF And Rst.EOF Then ' there are no reminders
docmd.close acform,"yourformname"
Rst.Close
Set Rst = Nothing
Set dbs = Nothing

Exit sub
Else:
'there must be reminders
me.form.visible=true



End If
End With
Rst.Close
Set Rst = Nothing
Set dbs = Nothing
 
Private Sub Form_Open(Cancel As Integer)
If (RecordsetClone.RecordCount = 0) Then
DoCmd.Close
Beep
MsgBox "There are no reminders.", vbInformation, "No Reminders Listed"
End If
End Sub
 

Users who are viewing this thread

Back
Top Bottom