WHERE clause in text Box

B

Barry A&P

I may just be burned out,,,,,

I am trying to create a textbox that displays a warning based on a combobox
on another form but my warning displays the "bound" field of the combo not
the displayed field..

heres what im using

="Warning !! " & forms![users][userID] & " You dont know what you are doing"

this is what i end up with
"Warning 3 you dont know what youre doing"

I want to get
"Warning Barry you dont know what youre doing"

i cant figure the textbox syntax for something to display username where
userID = forms![users][userID]

can i use a join or where clause inside the textbox? or do i have to do a
query elsewhere

any help would be appreciated
Barry
 
M

Mike Painter

Barry said:
I may just be burned out,,,,,

I am trying to create a textbox that displays a warning based on a
combobox on another form but my warning displays the "bound" field of
the combo not the displayed field..

heres what im using

="Warning !! " & forms![users][userID] & " You dont know what you are
doing"
DLookup would be one way. If the combobox displays the name you can use that
column
forms!users.userID.column(x)
this is what i end up with
"Warning 3 you dont know what youre doing"

I want to get
"Warning Barry you dont know what youre doing"

i cant figure the textbox syntax for something to display username
where userID = forms![users][userID]

can i use a join or where clause inside the textbox? or do i have to
do a query elsewhere

any help would be appreciated
Barry
 
A

Allen Browne

If the display column is the 2nd one, try:
="Warning !! " & [forms]![users][userID].Column(1) & " You dont know
what you are doing"

Note that the first column is zero, so the 2nd is Column(1).
 
B

Barry A&P

Allen thank you for your help

I found another post of yours with Dlookup as the combo box value changes

="Warning !! " & dlookup("[user]" , "users", "[userid] =
[forms]![users][usercombobox]")& " You dont know what you are doing"

can your suggestion of [forms]![users][userID].Column(1) be dependent on
[usercombobox]?

Allen Browne said:
If the display column is the 2nd one, try:
="Warning !! " & [forms]![users][userID].Column(1) & " You dont know
what you are doing"

Note that the first column is zero, so the 2nd is Column(1).

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Barry A&P said:
I may just be burned out,,,,,

I am trying to create a textbox that displays a warning based on a
combobox
on another form but my warning displays the "bound" field of the combo not
the displayed field..

heres what im using

="Warning !! " & forms![users][userID] & " You dont know what you are
doing"

this is what i end up with
"Warning 3 you dont know what youre doing"

I want to get
"Warning Barry you dont know what youre doing"

i cant figure the textbox syntax for something to display username where
userID = forms![users][userID]

can i use a join or where clause inside the textbox? or do i have to do a
query elsewhere

any help would be appreciated
Barry
 
A

Allen Browne

You can concatenate the contents of the combo into the 3rd string:

="Warning !! " & dlookup("[user]" , "users",
"[userid] = " & Nz([forms]![users][usercombobox],0))

If userid is text, you need extra quotes:
="Warning !! " & dlookup("[user]" , "users",
"[userid] = """ & [forms]![users][usercombobox] & """")

Explanation of the quotes:
http://allenbrowne.com/casu-17.html

The Nz() above was in case the combo was null, in which case the 3rd string
would have been just:
userid =
which is clearly not right.

You can use the Column() too property if needed.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Barry A&P said:
Allen thank you for your help

I found another post of yours with Dlookup as the combo box value changes

="Warning !! " & dlookup("[user]" , "users", "[userid] =
[forms]![users][usercombobox]")& " You dont know what you are doing"

can your suggestion of [forms]![users][userID].Column(1) be dependent on
[usercombobox]?

Allen Browne said:
If the display column is the 2nd one, try:
="Warning !! " & [forms]![users][userID].Column(1) & " You dont know
what you are doing"

Note that the first column is zero, so the 2nd is Column(1).

Barry A&P said:
I may just be burned out,,,,,

I am trying to create a textbox that displays a warning based on a
combobox
on another form but my warning displays the "bound" field of the combo
not
the displayed field..

heres what im using

="Warning !! " & forms![users][userID] & " You dont know what you are
doing"

this is what i end up with
"Warning 3 you dont know what youre doing"

I want to get
"Warning Barry you dont know what youre doing"

i cant figure the textbox syntax for something to display username
where
userID = forms![users][userID]

can i use a join or where clause inside the textbox? or do i have to do
a
query elsewhere
 

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