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!

Search Form not Recogising Function 1

Status
Not open for further replies.

krispi

MIS
May 16, 2002
281
GB
Hi - I have a search form I often use. It is created using a form with a number of unbound controls into which the user types in search criteria.

The VBA behind the form involves building an SQL query using the AddToWhere function.

In the database I'm currently trying to create, I am getting an error message relating to the AddToWhere saying that the Sub or Function is not defined. This is the first time I have encountered this - can anyone suggest a reason (and/or a solution) for this problem?

Many thanks
Chris
 
Make sure you spelled it correctly. Usually this error relates to misspelling.

John Borges
 
No, it's definitely correct, I am however using a different PC to my usual machine - is it possible that I need an add-in or library that isn't currently installed?
 
Is AddToWhere a custom function? Is there more than on function with the same name ?

John Borges
 
How are ya krispi . . . . .

Post the [blue]SQL[/blue] & [blue]AddToWhere[/blue] function . . .

Post the [blue]actual error message[/blue] . . .

Calvin.gif
See Ya! . . . . . .
 
Hi Ace Man - the code is as follows:

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

' Use values entered in text boxes in form to create criteria for WHERE clause.
'text box name on form 'Field name in Table 'blank info ' number of times run Addt
AddToWhere [Text1], "[JobTitle]", MyCriteria, ArgCount
'AddToWhere [Text6], "[Income]", MyCriteria, ArgCount
'AddToWhere [Combo31], "[TCOwner]", MyCriteria, ArgCount
' If no criterion specifed, return all records.
If MyCriteria = "" Then
MyCriteria = "True"
End If

' Create SELECT statement.
MyRecordSource = MySQL & MyCriteria

' set record source to Subform
Me![TblDetail subform].Form.RecordSource = MyRecordSource


And the error message is: Compile Error: sub or Function Not Defined

Any help gratefully received.
 
The function "AddtoWhere" is not an Access pre-defined function, but an user-defined function. You will need to look for that "AddtoWhere" function in your original Access code.

John Borges
 
Thanks very much - it's been a while and I had forgotten that bit!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top