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

open form, trigger query, open form if query returns results

Status
Not open for further replies.

jaydeebe

IS-IT--Management
Nov 14, 2003
169
GB
This could just be a syntax problem. When my main form loads I want a popup form to open if a query returns any results. I'm not sure how to call the query properly.

Private Sub Form_Open(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String

subfrmFutureLoans.Requery
subfrmCurrentLoans.Requery

If qryOverdue Is Not Null Then
stDocName = "frmOverdue"
DoCmd.OpenForm stDocName, , , stLinkCriteria

End Sub
 
What is qryOverdue ? The name of a saved query ?
You may consider the DCount or DLookUp function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Dcount will do! thanks for the pointer PHV!

Private Sub Form_Open(Cancel As Integer)

Dim count As Integer
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmOverdue"
count = DCount("ID", "qryOverdue")

If count > 0 Then
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top