textbox and combobox

J

JohnE

I have a mainform and a subform. In the continuous subform there is a
combobox that has the id and name. Next to it there is a textbox that is to
show info regarding the name from the combobox. The info that is to populate
the txtbox comes from a different table. Currently I am trying the following;

Me.ChargeAccountType = "SELECT ChargeAccountType FROM ChargeAccountsQ WHERE
ChargeAccountType = Me.ChargeAccountID.Column(1)"

but only get in the txtbox what is between the quotes.

How should this be written to get the info?

Thanks...John
 
M

Marshall Barton

JohnE said:
I have a mainform and a subform. In the continuous subform there is a
combobox that has the id and name. Next to it there is a textbox that is to
show info regarding the name from the combobox. The info that is to populate
the txtbox comes from a different table. Currently I am trying the following;

Me.ChargeAccountType = "SELECT ChargeAccountType FROM ChargeAccountsQ WHERE
ChargeAccountType = Me.ChargeAccountID.Column(1)"

but only get in the txtbox what is between the quotes.


That would be more like:

Me.ChargeAccountType = DLookup("ChargeAccountType", _
"ChargeAccountsQ", "ChargeAccountType = " _
& Me.ChargeAccountID.Column(1))

But that may be kind of slow. It is usually better to
change the row source query to link to the ChargeAccountsQ
table and include the type field. Then you would not need
any code because the text box could just use an expression
like =ChargeAccountID.Column(2)
 
J

JohnE

'Mr Barton, your second idea was the ticket for this. Tough to see the
forest if not for the trees' sometimes.
Thanks.
John
 
M

Marshall Barton

JohnE said:
'Mr Barton, your second idea was the ticket for this. Tough to see the
forest if not for the trees' sometimes.

Can't have a forest without the trees ;-)

Glad to help.
 

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