A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Query two fields into one combo box



 
 
Thread Tools Display Modes
  #1  
Old May 24th, 2004, 08:31 PM
JohnLute
external usenet poster
 
Posts: n/a
Default Query two fields into one combo box

tblCGStyles has two fields:
txtCodeID (key)
txtCorrugatedStyles

cbStyle in my form queries both of these fields.

How do I get the two fields to display in the cbStyle after selecting? Currently, only txtCodeID displays.
  #2  
Old May 24th, 2004, 08:54 PM
Ted Allen
external usenet poster
 
Posts: n/a
Default Query two fields into one combo box

Hi John,

A combo box will only display one column. But, there are
a few ways that you can do what you want to do.
Following are a few examples, both are variations of
concatenating the two fields into one:

1. Change your query such that the second column is a
calculated field that concatenates the two, and then hide
the first column (set the width to 0)

2. Concatenate the two colums as column 0 (the first
one) and set txtCodeID as the second column (column 1).
Change the combo properties such that it is bound to
column 1 instead of 0 (the default).

There are pro's and con's to each method. I often use
method # 1 if I want to do something like this.

The calculated field for your concatenation would look
something like:

[txtCodeID] & " - " & txtCorrugatedStyles

Where you would replace the " - " with whatever you would
want to display between the two column values.

HTH, Ted Allen
-----Original Message-----
tblCGStyles has two fields:
txtCodeID (key)
txtCorrugatedStyles

cbStyle in my form queries both of these fields.

How do I get the two fields to display in the cbStyle

after selecting? Currently, only txtCodeID displays.
.

  #3  
Old May 24th, 2004, 08:57 PM
Wayne Morgan
external usenet poster
 
Posts: n/a
Default Query two fields into one combo box

A combobox won't display both in the textbox window, just in the drop down.
To display the other column after the selection, place a textbox next to the
combobox. Set its Locked property to Yes and, if desired, its Enabled
property to no. Set the control source of the textbox to

=NameOfCombobox.Column(1)

The column number is zero based, so the first column is 0, the second is 1,
etc. If you get an error, make sure that the name of the combobox is NOT the
same as the name of the field it is bound to or the name of any other item.

--
Wayne Morgan
Microsoft Access MVP


"JohnLute" wrote in message
...
tblCGStyles has two fields:
txtCodeID (key)
txtCorrugatedStyles

cbStyle in my form queries both of these fields.

How do I get the two fields to display in the cbStyle after selecting?

Currently, only txtCodeID displays.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:54 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.