issues with a numbertext search (1 Viewer)

munkeyroot

Registered User.
Local time
Today, 16:51
Joined
Jan 13, 2011
Messages
76
Hi everyone

i am having a little trouble with some code for a search box.
on my main form i have a quote Field "Quote Rev Number" - the quote could be a number or numbertext.

i have an unbound text box called txt_QuoteRevSearch

then a command button with the below script:

Private Sub btn_qouterevsearch_Click()
If IsNull(txt_QuoteRevSearch) = False Then
Me.Recordset.FindFirst "[Quote Rev Number]=" & txt_QuoteRevSearch
Me!txt_QuoteRevSearch = Null
If Me.Recordset.NoMatch Then
MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
Me!txt_QuoteRevSearch = Null
End If
End If
End Sub


if i type the quote number with numbers and text:
"800500rev1": i get a syntax error: (missing operator) in expression

if i type the quote number:
"800500": i get Data type mismatch in criteria Expression. .. i think this is because i switched the datatype from number to short text

The reason i am using numbers and text is that each main form is a 1 quote for a customer - however their could be variations or addition for this one quote.
so the original Quote number would be 800500 then and new Quote would be made for a second option but with a new quote number "800500rev1" for instance.


hope this make sense

cheers munk
 

isladogs

MVP / VIP
Local time
Today, 16:51
Joined
Jan 14, 2017
Messages
18,275
Use text delimiters as below

Private Sub btn_qouterevsearch_Click()
If IsNull(txt_QuoteRevSearch) = False Then
Me.Recordset.FindFirst "[Quote Rev Number]='" & txt_QuoteRevSearch &"'"
Me!txt_QuoteRevSearch = Null
If Me.Recordset.NoMatch Then
MsgBox "No record found", vbOKOnly + vbInformation, "Sorry"
Me!txt_QuoteRevSearch = Null
End If
End If
End Sub


 

munkeyroot

Registered User.
Local time
Today, 16:51
Joined
Jan 13, 2011
Messages
76
Hey Ridders
oh course ! i feel like a dumb as now.. cheers mate worked a treat bud

Munk
 

Users who are viewing this thread

Top Bottom