Probvlems when No Data returned with QBF

  • Thread starter Thread starter Scott A
  • Start date Start date
S

Scott A

I've got a form that uses several combo boxes to let the
user enter parameters and run a query. The results of the
query are displayed on the form. I'd like to make two
enhancements and am looking for some suggestions. Both
enhancements have to do with the way the form handles
searches that result in no data:

1. I've got a 'Clear' button that is supposed to remove
the values from the combo boxes so that the user can enter
new parameters. It works just fine when the query
produces results, but if the query does not result in any
records being displayed, the values persist in the
controls even after the user clicks the 'Clear' button.


Here's the code behind the button:

Private Sub cmdClearSearch_Click()

On Error GoTo Err_cmdClearSearch_Click

'Clear content of all search controls
Me!txtEQnumber = Null
Me!cboEQtype = Null
Me!cboEQdept = Null
Me!cboEQloc = Null
Me!cboEQemp = Null
Exit_cmdClearSearch_Click:
Exit Sub

Err_cmdClearSearch_Click:
MsgBox Err.Description
Resume Exit_cmdClearSearch_Click

End Sub

What can I do to improve the code behind this button (or
behind some other event) that will clear the parameters
after the query returns no records?

2. I would love to be able to display a message to the
user when the query does not return any records. Right
now, they only see a blank page. I know how to handle
this with the On_No_Data event in a report, but that event
is not available on a form. Anybody know how to fake it
for a form?

Thanks!

Scott
 
Question 1 ----

Do you have AllowAdditions turned off? If you do, change your code to:
Me.AllowAdditions = True
'Clear content of all search controls
Me!txtEQnumber = Null
Me!cboEQtype = Null
Me!cboEQdept = Null
Me!cboEQloc = Null
Me!cboEQemp = Null
Exit_cmdClearSearch_Click:
Me.AllowAdditions = False
Exit Sub

Question 2 ---------------

If Me.RecordsetClone.RecordCount = 0 Then
MsgBox .................
End If
 
Back
Top