Help with code.. Txt box

  • Thread starter Thread starter MarieG
  • Start date Start date
M

MarieG

Hello all,

I've inherited this database and I cannot figure out why this txt field is
not working.. the code is below. When I fill in the phone number in the
text box, it should show me the data that corresponds to that number, but it
says no records found?

Thanks so much!


Private Sub txtServNo_AfterUpdate()

'If criteria is entered in this field, start building (or continue building)
the search criteria (searchSQL) SQL string
If txtServNo.Value <> "" Then
If andFlag = True Then
searchSQL = searchSQL + " AND service_no = '" + txtServNo.Value + "'"
Else
searchSQL = "SELECT * FROM WirelessInventory where service_no = '" +
txtServNo.Value + "'"
andFlag = True
End If
End If

End Sub
 
Hi MarieG,

There was an extra line on the 4th last line
andFlag
I removed that line and changed your + signs to & signs.


Private Sub txtServNo_AfterUpdate()

'If criteria is entered in this field, start building (or continue building)
the search criteria (searchSQL) SQL string
If txtServNo.Value <> "" Then
If andFlag = True Then
searchSQL = searchSQL & " AND service_no = '" & txtServNo.Value &
"'"
Else
searchSQL = "SELECT * FROM WirelessInventory where service_no = '" &
txtServNo.Value & "'"
End If
'Debug.Print strSQL
End If

End Sub


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Thanks Jeanette! But, I copied your code to the database and when I run it
it shows an error message "Compile Error"??
 
While in the code window, choose Debug | Compile

Which line is highlighted when you get the compile error?


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
Ken,
This is the input mask for the field the number is coming from.. Also it is
a text field.
!\(999") "000\-0000;0;_

So, I'm guessing that I should take that masking out of the code I put up?

Thanks,

Marie
 
Back
Top