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!

having some trouble

Status
Not open for further replies.

scimatic

Technical User
Aug 30, 2004
19
US
i'm trying to create a search form for access just like the one explained in faq702-1177 and i'm getting an error that says: Compile error, expected variable or procedure, not module and the error points to this line: AddToWhere [Find1] in the following code: Could someone help me out or tell me were i could download a working version?

Private Sub Command23_Click()
On Error GoTo Err_Command23_Click

Dim MySQL As String, MyCriteria As String, MyRecordSource As String
Dim ArgCount As Integer
' Initialize SELECT statement.
MySQL = "SELECT * FROM tblInfo WHERE "

' Use values entered in text boxes in form header to create criteria for WHERE clause.
'text box name on form 'Field name in Table 'blank info ' number of times run Add
AddToWhere [Find1], "FName", MyCriteria, ArgCount
AddToWhere [Find2], "LName", MyCriteria, ArgCount


' If no criterion specifed, return all records.
If MyCriteria = "" Then
MyCriteria = "True"
End If

' Create SELECT statement.
MyRecordSource = MySQL & MyCriteria

' Optional Order By clause
If Me![Find1] <> "" Then
MyRecordSource = MySQL & MyCriteria & " ORDER BY FName"
ElseIf Me![Find2] <> "" Then
MyRecordSource = MySQL & MyCriteria & " ORDER BY LName"
Else
MyRecordSource = MySQL & MyCriteria & " ORDER BY FName"
End If


' set record source to Subform
Me!frmResults.Form.RecordSource = MyRecordSource


Exit_Command23_Click:
Exit Sub

Err_Command23_Click:
MsgBox Err.Description
Resume Exit_Command23_Click

End Sub
 
This seems to be one of the best examples for searching at the thread below
Thread702-563930

Hope this helps
Hymn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top