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

if there are records open form

Status
Not open for further replies.

GabberGod

IS-IT--Management
Nov 16, 2003
73
AU
i need some help, basicly what im trying to do is:

if a field is changed, run a query, if this selects 1 or more record, open a form.

 
I use this code to open a form if the query qryOverdue returns records. Use the dcount function to count the number of records returned by the query. If there are any then form is opened, else nothing happens.

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
 
What happens if you have a parameter included in the query/ I get a message asking for the parameter.
chiefvj
 
What is the parameter's source? A text box, a dialog ?

You could set the parameter to accept no input by adding

Parameter Or parameter Is Null

to the criteria in design grid, where parameter is whatever your parameter source is.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top