Update Combo Box


A

alhotch

I have a Combo Box on a form by the name of DNTReason. The Control Soucre for
this CB is =DLookUp("[DNTReason]","[DNTReason]","[DNTReason.DNTReasonID] =
" & [DNTReservations.DNTReason]) . This works as advertised returning the
value (text data) from the [DNTREASON].[DNTREASON] "table.field".

Now remember, this is a Combo Box. What I would like to do is use this Combo
Box to change its value from what the DLookUp reported to some other value in
the underlying table. Since DLookUp has already given me the value of the
Combo Box, clicking on the "down arrow" of the Combo Box will display
available values from the DNTReason table but I can not select any data. The
form just "beeps" at me.

I tried to put the DLookUp in a macro annd change the Control Source back to
DNTReason but it gets confused. Any ideas as to how I can use DLookUp to
"prime" the field but yet, let me change its value through the Combo Box
"down arrow" ?
 
Ad

Advertisements

J

Jeff Boyce

It's a bit uncommon to use a DLookup() as a Control Source.

Have you looked into using a query instead?

As for the apparently empty values, have you inspected the number of columns
and column width properties?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
A

alhotch

Hi Jeff. By using the DLookUIp function, I can display only the value (text)
of the combo box and not the numeric representatrion. The idea is to display
the value as one would with a "Text Box" but still have the functionality of
a "Combo Box, in that I could "change" the value in the Combo Box and have it
displayed as if it were a Text Box.

Jeff Boyce said:
It's a bit uncommon to use a DLookup() as a Control Source.

Have you looked into using a query instead?

As for the apparently empty values, have you inspected the number of columns
and column width properties?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

alhotch said:
I have a Combo Box on a form by the name of DNTReason. The Control Soucre
for
this CB is =DLookUp("[DNTReason]","[DNTReason]","[DNTReason.DNTReasonID]
=
" & [DNTReservations.DNTReason]) . This works as advertised returning
the
value (text data) from the [DNTREASON].[DNTREASON] "table.field".

Now remember, this is a Combo Box. What I would like to do is use this
Combo
Box to change its value from what the DLookUp reported to some other value
in
the underlying table. Since DLookUp has already given me the value of the
Combo Box, clicking on the "down arrow" of the Combo Box will display
available values from the DNTReason table but I can not select any data.
The
form just "beeps" at me.

I tried to put the DLookUp in a macro annd change the Control Source back
to
DNTReason but it gets confused. Any ideas as to how I can use DLookUp to
"prime" the field but yet, let me change its value through the Combo Box
"down arrow" ?


.
 
J

Jeff Boyce

There's another way, actually quite common and designed in, to get the
combobox to display the value rather than the code.

Check the properties of the combobox, looking for the column count (how
many) and the column width (how wide) properties.

For example, a common approach to comboboxes is to use a query that returns
the code (ID) and the value. First ensure that 2 columns (column count) are
called for, then make sure the width of the first column is zero.

That way, you see the value, but the code/ID gets stored.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

alhotch said:
Hi Jeff. By using the DLookUIp function, I can display only the value
(text)
of the combo box and not the numeric representatrion. The idea is to
display
the value as one would with a "Text Box" but still have the functionality
of
a "Combo Box, in that I could "change" the value in the Combo Box and have
it
displayed as if it were a Text Box.

Jeff Boyce said:
It's a bit uncommon to use a DLookup() as a Control Source.

Have you looked into using a query instead?

As for the apparently empty values, have you inspected the number of
columns
and column width properties?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

alhotch said:
I have a Combo Box on a form by the name of DNTReason. The Control
Soucre
for
this CB is
=DLookUp("[DNTReason]","[DNTReason]","[DNTReason.DNTReasonID]
=
" & [DNTReservations.DNTReason]) . This works as advertised
returning
the
value (text data) from the [DNTREASON].[DNTREASON] "table.field".

Now remember, this is a Combo Box. What I would like to do is use this
Combo
Box to change its value from what the DLookUp reported to some other
value
in
the underlying table. Since DLookUp has already given me the value of
the
Combo Box, clicking on the "down arrow" of the Combo Box will display
available values from the DNTReason table but I can not select any
data.
The
form just "beeps" at me.

I tried to put the DLookUp in a macro annd change the Control Source
back
to
DNTReason but it gets confused. Any ideas as to how I can use DLookUp
to
"prime" the field but yet, let me change its value through the Combo
Box
"down arrow" ?


.
 
Ad

Advertisements

A

alhotch

Yes, Jeff. You are absolutely correct ! I had been focused so much on the
DLookUp fuction (I had used it for "parsing" another combo box "value" to
text box - no changes required) that I forgot the simplicity of displaying
the data from the combo box - Column Count=2 and Column Width=0";2.5"

Data can now be changed and the data displayed correctly. Thank you for
clearing my "self induced fog".

Jeff Boyce said:
There's another way, actually quite common and designed in, to get the
combobox to display the value rather than the code.

Check the properties of the combobox, looking for the column count (how
many) and the column width (how wide) properties.

For example, a common approach to comboboxes is to use a query that returns
the code (ID) and the value. First ensure that 2 columns (column count) are
called for, then make sure the width of the first column is zero.

That way, you see the value, but the code/ID gets stored.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

alhotch said:
Hi Jeff. By using the DLookUIp function, I can display only the value
(text)
of the combo box and not the numeric representatrion. The idea is to
display
the value as one would with a "Text Box" but still have the functionality
of
a "Combo Box, in that I could "change" the value in the Combo Box and have
it
displayed as if it were a Text Box.

Jeff Boyce said:
It's a bit uncommon to use a DLookup() as a Control Source.

Have you looked into using a query instead?

As for the apparently empty values, have you inspected the number of
columns
and column width properties?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

I have a Combo Box on a form by the name of DNTReason. The Control
Soucre
for
this CB is
=DLookUp("[DNTReason]","[DNTReason]","[DNTReason.DNTReasonID]
=
" & [DNTReservations.DNTReason]) . This works as advertised
returning
the
value (text data) from the [DNTREASON].[DNTREASON] "table.field".

Now remember, this is a Combo Box. What I would like to do is use this
Combo
Box to change its value from what the DLookUp reported to some other
value
in
the underlying table. Since DLookUp has already given me the value of
the
Combo Box, clicking on the "down arrow" of the Combo Box will display
available values from the DNTReason table but I can not select any
data.
The
form just "beeps" at me.

I tried to put the DLookUp in a macro annd change the Control Source
back
to
DNTReason but it gets confused. Any ideas as to how I can use DLookUp
to
"prime" the field but yet, let me change its value through the Combo
Box
"down arrow" ?


.


.
 

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