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!

List / Find Procedure Help

Status
Not open for further replies.

Ausburgh

Programmer
Jul 21, 2004
62
US
Please Help!

I'm trying to list all the records in one of my databases (Trip) by searching the "TravelAmt" field which is a numeric (a double to be specific)field.

I'm getting a:

---
"Run-time error '3464':
Data type mismatch in criteria expression
----

I know I can't use Chr$() (because it is a string) but I don't know what to put in there either.

My code:
------------------------
Private Sub List2_Click()

Dim Template As String

Template = "[TravelAmt] = " & Chr$(10) & List2.List(List2.ListIndex) & Chr$(10)
Trip.AccessTrip.Recordset.FindFirst Template
End Sub

-------

Thanks in advance
 
Try
Code:
Template = "[TravelAmt] = " & Val(List2.List(List2.ListIndex))

[small]No! No! You're not thinking ... you're only being logical.
- Neils Bohr[/small]
 
Also, Chr(10) is the NewLine Character. Chr$(34) is double-quotes. Try:

To search for numerics, leave off the quotes:

Template = "[TravelAmt] = " & List2.List(List2.ListIndex)

FYI, When searching strings:

Template = "[TravelAmt] = " & Chr$(34) & List2.List(List2.ListIndex) & Chr$(34)

or even

Template = "[TravelAmt] = """ & List2.List(List2.ListIndex) &
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top