query not working by changing field type from number to text

rehanemis

Registered User.
Local time
Today, 20:06
Joined
Apr 7, 2014
Messages
195
Hi,
I have changed the data type of field "EmpID" from number to text and the query not working now. Any suggestion?
Capture.JPG
 
you need to wrap strings in single quotes
"EmpID = '" & screen.actvieControl & "'"
 
"[EmpID] = '" & Nz([Screen].[ActiveControl], 0) & "'"
 
What is the RowSource of cboSearch?

What are your table fields and their datatypes?
 
I want to show the relevant records in subform by choosing the EmpID from drop down. It was working well on numeric data type but not on text.
 
I never use macros, so I'm not familiar with the double = signs that you showed in your first image.

Did you replicate them in your adjusted expression based on the suggestions from majp and myself?

Please post the expression you have now. (Please copy and paste, don't post an image)

Is there any reason you're not using code instead?
 
I never use macros, so I'm not familiar with the double = signs that you showed in your first image.

Did you replicate them in your adjusted expression based on the suggestions from majp and myself?

Please post the expression you have now. (Please copy and paste, don't post an image)

Is there any reason you're not using code instead?
Code:
="[EmpID] ='" & Str(Nz([Screen].[ActiveControl],0) & "'")
I am not much familiar with code to search record in subform.
 
What is the name of your subform control?

(Note, this might be different from the name of the actual subform used as its SourceObject)
 
I'll have to get back to you tomorrow. It's late here.

Someone else might pick up the pace in the meanwhile
 
None of this would be necessary if using link Master and Child fields in the subform properties. Look on the Data tab.

But...if you insist on using search for record (not necessary)

The macro builder helps you by suggesting field names when you begin typing. I would just double click those.

Also, I specify the actual field name rather than relying on ActiveControl. I don't know if it would ever cause a problem, but what would happen if that control suddenly wasn't active?

Try

="[EmpID] =" & [EmpID]
 

Users who are viewing this thread

Back
Top Bottom