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

Help please!

Status
Not open for further replies.

quinny1

Programmer
Oct 17, 2000
12
GB
Hi All,
I have a form which allows the user to enter parameters for a filter on another form. This is done by constructing an sql "where" clause and passing it as a filter to the calling form. If the combination of parameters returns no values I want to be able to trap the error and return to the parameter screen.Could anyone suggest a solution. Thanks in advance.
Quinny1


 
You could do a number of things, such as:

1) execute the query from the parameter form and only open up the other form if the recordcount doesn't equal 0

2) in the Form_Open event of the filter form you could check to see if the recordcount is 0 and if so cancel the opening of the form
 
Thanks Schof,
How do I get the recordcount? I tried on the recordsource but that itself is a query. So I thought there may be some way of getting the number of recs from the filter?
 
You get if from the form's recordset like this...

Current Form
If Me.Recordset.RecordCount = 0 Then ...

Other (Open) Form
Dim stDocName As String ' Name of the form
Dim stLinkCriteria As String ' Filter criteria (if any)
Dim stSearchCriteria As String ' Search criteria (if any)

stDocName = &quot;<FORM_NAME>&quot;
stLinkCriteria = &quot;<FILTER_CRITERA>&quot;
stSearchCriteria = &quot;<SEARCH_CRITERIA>&quot;

DoCmd.openForm stDocName, , , stLinkCriteria, , , stSearchCriteria

If Forms(stDocName).Recordset.RecordCount = 0 Then ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top