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

Compile Error

Status
Not open for further replies.

bill1one

Programmer
Sep 29, 2004
93
US
I keep getting the following compile error:
"User defined type not defined"

I have looked through my code several times and can't see anything.

Here is my code. Any suggestions?

Private Sub cmdSearch_Click()
Dim strSQL As String, strOrder As String, strWhere As String
Dim dbNm As Database
Dim qryDef As QueryDef
Set dbNm = CurrentDb()

strSQL = "SELECT tblParticipants.ID, tblParticipants.Name " & _
"FROM tblParticipants"

strWhere = "WHERE"

strOrder = "ORDER BY tblParticipants.Name;"

If Not IsNull(Me.txtTitle) Then
strWhere = strWhere & " (tblParticipants.Name) Like '*" & Me.txtName & "*' AND"
End If


strWhere = Mid(strWhere, 1, Len(strWhere) - 5)


Me.lstName.RowSource = strSQL & " " & strWhere & "" & strOrder

lstName.SetFocus

End Sub
 
It does look OK.

Granted that I don't know exactly what info you base your searches on but the only thing that looks out of place from the code is that you are searching if txtTitle is Null and not txtName, is this on purpose?

Regards,
gkprogrammer
 
How are ya bill1one . . . . .

In:
Code:
[blue]strWhere = strWhere & " (tblParticipants.Name) Like '*" & Me.txtName & "*'  AND"

strWhere = Mid(strWhere, 1, Len(strWhere) - [purple][b]5[/b][/purple])[/blue]
[purple]5[/purple] leaves no leading space for concating [blue]Order By[/blue]. Error is generated here.

Change [purple]5[/purple] to [purple]4[/purple]!

Calvin.gif
See Ya! . . . . . .
 
I have made the suggested changes and continue to get the same compiler error?
 
It seems to be getting hung up at the top, at
dbNm As Database
 
bill1one . . . . .

You still needed to change 5 to 4!

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top