Help with code.. Txt box

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
 
J

Jeanette Cunningham

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
 
M

MarieG

Thanks Jeanette! But, I copied your code to the database and when I run it
it shows an error message "Compile Error"??
 
J

Jeanette Cunningham

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
 
M

Mary Rose Wertheimer

dfdsfsdfsdfd
MarieG said:
Thanks Jeanette! But, I copied your code to the database and when I run
it
it shows an error message "Compile Error"??
 
M

MarieG

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top