Full Version: Question About Searchforrecord
UtterAccess Discussion Forums > Microsoft® Access > Access Macros
baba
I'm pretty new with Access. I want to make a form that updates its field based on the database that has been filled previously using combobox.
For example:
combobox provide name and when selected the other fields (address, phone number, etc) update based on the table id.
I have been pretty successful but when the id was changed to other type of data (like 'text'), the field refuses to update. does this only works with number type?
thx before. btw i use access 2010, the where condition: ="[ID]=" & [Screen].[ActiveControl]
RJD
welcome2UA.gif
If [ID] and the control contain text, then the contents should be enclosed in quotes...
"[ID]='" & [... your control name ...] & "'"
Note the single-quote in two places: after the = and at the end, enclosed in double-quotes.
HTH
Joe
baba
thx joe it totally works!
m not that good (yet) even with expression problems, would you kindly explain thoroughly what's with the use of single-quote in that problem?
Omean i know it failed to match because the variable before is for number not strings, but i dont get it with the structure of the expression.
thank you very much
RJD
Hi again: Glad that works for you.
On a WHERE criteria, numerics and text are treated differently. Numerics stand alone and do not need quote marks. Text values must be enclosed in quotes.
Since the WHERE expression already has double-quotes in its syntax, the single-quotes are substituted where more quotes are needed (using more double-quotes will confuse the syntax interpretation). If the value after the equal sign is named explicitly, then it would be something like this:
"[ID]='ABC'"
... indicating that ABC is a text value.
The syntax I suggested in my first post causes the WHERE statement to be interpreted this way when the control value is inserted.
HTH
Joe
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.