search on numeric value

kenjones

Registered User.
Local time
Today, 05:15
Joined
Jun 1, 2012
Messages
16
The following works when I am searching a form on a value in a sub-form where the value is text
-------------------------------

Private Sub find_boats_by_enq_no_Click()

Dim stDocName As String
Dim strSQL As String
Dim trz As String
trz = InputBox("Enquiry number??")

stDocName = "find_boats_by_enq_no"

strSQL = "SELECT * FROM boats INNER JOIN prices ON boats.[boats-prices#] = prices.[boats-prices#] " _
& "WHERE prices.[stn-enquiry-number-1]= '" & trz & "'"

Me.RecordSource = strSQL

End Sub
------------------------------

What changes do I need to make if "prices.[stn-enquiry-number-1]" is a number rather than text. I'm thinking I dont require some of the "dims" and I'm not sure if I don't need to do something with the quote marks
 
Try this..
Code:
Private Sub find_boats_by_enq_no_Click()
    Dim stDocName As String
    Dim strSQL As String
    Dim [COLOR=Red]trz As Long[/COLOR]
    trz = [URL="http://www.techonthenet.com/access/functions/datatype/clng.php"][COLOR=Red]CLng([/COLOR][/URL]InputBox("Enquiry number??")[COLOR=Red])[/COLOR]

    stDocName = "find_boats_by_enq_no"

    strSQL = "SELECT * FROM boats INNER JOIN prices ON boats.[boats-prices#] = prices.[boats-prices#] " _
    & "WHERE prices.[stn-enquiry-number-1]=[COLOR=Red] " & trz[/COLOR]
    Me.RecordSource = strSQL
End Sub
 

Users who are viewing this thread

Back
Top Bottom