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!

Change Parameter Criteria to Visual Basic 1

Status
Not open for further replies.

Garridon

Programmer
Mar 2, 2000
718
US
I have a keyword search in my database that uses a query to trigger a paramenter box. This is what's in the field:

Like "*" & [Enter Keyword to Search For] & "*"

It then opens a form that displays all the records that meet the keyword.

Unfortunately, if the user types in a keyword that isn't in a record, the form still opens to no records. I'd like to convert the parameter criteria to visual basic so that if no records are found, a message box could be triggered instead of the using getting the blank form. However, I'm still a beginner at Visual Basic. Can anyone help?

Thanks!

Linda Adams
Visit my web site for writing and Microsoft Word tips: Official web site for actor David Hedison:
 
Linda

You could try this in the 'No Data' event of the report instead of modifying your search criteria. You may need to modify the message text but what it does is to cancel the report opening and flash up a message if the report would show no data.

On Error GoTo ErrorHandler
Dim str As String
str = MsgBox("No records exist for the period selected", vbOKOnly + vbInformation, "No Data")

Cancel = True

ExitReport:
Exit Sub

ErrorHandler:
MsgBox Err.Description
Resume ExitReport

Hope it helps

Nigel
 
In Form Open
If the form is bound check

If Me.RecordSetClone.RecordCount = 0 Then
Cancel = true
Exit Sub
End if


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top