Reference to form textfield

L

Leif Nystrom

I have following very simple code in a listbox' row source:
SELECT DISTINCT [Name1] & [Name2] FROM Table1 WHERE [Name3]
= "Hugo" i.e selecting Name1 and Name2 from the value in
the Name3 field. Works correcly but when replacing "Hugo"
with the Form textbox name return nothing in the list box.
Why? Any sugestions to correct the problem?
Thanks
Leif
 
J

John Vinson

I have following very simple code in a listbox' row source:
SELECT DISTINCT [Name1] & [Name2] FROM Table1 WHERE [Name3]
= "Hugo" i.e selecting Name1 and Name2 from the value in
the Name3 field. Works correcly but when replacing "Hugo"
with the Form textbox name return nothing in the list box.
Why? Any sugestions to correct the problem?
Thanks
Leif

The criterion should be

= [Forms]![nameofyourform]![nameofthetextbox]
 
G

Guest

-----Original Message-----
I have following very simple code in a listbox' row source:
SELECT DISTINCT [Name1] & [Name2] FROM Table1 WHERE [Name3]
= "Hugo" i.e selecting Name1 and Name2 from the value in
the Name3 field. Works correcly but when replacing "Hugo"
with the Form textbox name return nothing in the list box.
Why? Any sugestions to correct the problem?
Thanks
Leif

The criterion should be

= [Forms]![nameofyourform]![nameofthetextbox]



.
Thanks John for the reply. I have tried that and a number
of other things but the only way to get the SELECT code to
fill the listbox is to hardcode(textstr)it i.e
xxx= "txtstr". I have the same problem trying to use Class
Module code, only hardcoding helps.
I cant understand why. Any further help??
Leif
 
J

John Vinson

Thanks John for the reply. I have tried that and a number
of other things but the only way to get the SELECT code to
fill the listbox is to hardcode(textstr)it i.e
xxx= "txtstr". I have the same problem trying to use Class
Module code, only hardcoding helps.
I cant understand why. Any further help??
Leif

Please post your code, and/or the SQL of your query. It may be some
missing quotemarks - what's the datatype of xxx?
 
L

Leif Nystrom

John,
Thanks for having patience with me
This is what I am doing:
SELECT [FödNamn] & " f." & [FödDatum] FROM Birth WHERE
AnKodF="1845-04-18 Jöns"
Födnamn = Column 5 in Table Birth
FödDatum = Column 6 in Table Birth
AnKodF = Column 3 in Table Birth
1845-04-18 Jöns = text appering in certain rows in column 3
This code works well but when moving to next Post on the
form also the AnkodF changes.With thousendths of namns it
is not a good way to in the 'look-up' text.

Instead I have a textbox on the form generation the look-
up text. Textbox name is tpval. Codes that should doit is:
SELECT [FödNamn] & " f." & [FödDatum] FROM Birth WHERE
AnKodF=tpval
Returns nothing

SELECT [FödNamn] & " f." & [FödDatum] FROM Birth WHERE
AnKodF= " ' & tpval & ' "
Return all the names in column 3.
 

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