How to return the primary key from a combo box

I have a table containing two columns 
Column 1: Primary key 
Column 2: Name.  

I want to create an unbound combo box that shows the name but returns the PK.
I have these properties set:

Control source:  <is empty>
Row source type: table/query
Bound column: 1
Row source: <I have a select that returns the desired records>

In cboClient_AfterUpdate() I look at debug.print cboClient.Value and I see
the name.  I need the PK so I can construct the query for the next combo box.


How do I get the PK

Thanks for the help

-- 
Message posted via http://www.accessmonster.com

0
new2access123
2/20/2010 4:57:48 AM
access.modulesdaovba 1670 articles. 0 followers. Follow

5 Replies
981 Views

Similar Articles

[PageSpeed] 10

On Sat, 20 Feb 2010 04:57:48 GMT, "new2access123 via AccessMonster.com"
<u58027@uwe> wrote:

>I have a table containing two columns 
>Column 1: Primary key 
>Column 2: Name.  
>
>I want to create an unbound combo box that shows the name but returns the PK.
>I have these properties set:
>
>Control source:  <is empty>
>Row source type: table/query
>Bound column: 1
>Row source: <I have a select that returns the desired records>
>
>In cboClient_AfterUpdate() I look at debug.print cboClient.Value and I see
>the name.  I need the PK so I can construct the query for the next combo box.

You need ColumnCount = 2, Bound Column 1, ColumnWidths property

0";1"

(or some other nonzero width for the name).


-- 

             John W. Vinson [MVP]
0
John
2/20/2010 6:42:12 AM
I have these propeerties set...
row source : SELECT Client.Name FROM Client ORDER BY [Name]; 
ColumnCount:  2
Bound Column: 1
ColumnWidths: 0";2"

In cboClient_AfterUpdate() I look at debug.print cboClient.Value and I see
the still see the name from column 2 not the PK from column 1.

Is there something I am missing? 


John W. Vinson wrote:
>>I have a table containing two columns 
>>Column 1: Primary key 
>[quoted text clipped - 10 lines]
>>In cboClient_AfterUpdate() I look at debug.print cboClient.Value and I see
>>the name.  I need the PK so I can construct the query for the next combo box.
>
>You need ColumnCount = 2, Bound Column 1, ColumnWidths property
>
>0";1"
>
>(or some other nonzero width for the name).
>

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201002/1

0
new2access123
2/20/2010 7:10:29 AM
I see my error.  Left out the PK from the SELECT field list.  Thank ypu for
the help.


new2access123 wrote:
>I have these propeerties set...
>row source : SELECT Client.Name FROM Client ORDER BY [Name]; 
>ColumnCount:  2
>Bound Column: 1
>ColumnWidths: 0";2"
>
>In cboClient_AfterUpdate() I look at debug.print cboClient.Value and I see
>the still see the name from column 2 not the PK from column 1.
>
>Is there something I am missing? 
>
>>>I have a table containing two columns 
>>>Column 1: Primary key 
>[quoted text clipped - 7 lines]
>>
>>(or some other nonzero width for the name).

-- 
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/201002/1

0
new2access123
2/20/2010 7:18:00 AM
John hit the nail on the head.  See a visual sample here (Column Widths):
http://office.microsoft.com/en-us/access/HA011730581033.aspx



-- 
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"John W. Vinson" wrote:

> On Sat, 20 Feb 2010 04:57:48 GMT, "new2access123 via AccessMonster.com"
> <u58027@uwe> wrote:
> 
> >I have a table containing two columns 
> >Column 1: Primary key 
> >Column 2: Name.  
> >
> >I want to create an unbound combo box that shows the name but returns the PK.
> >I have these properties set:
> >
> >Control source:  <is empty>
> >Row source type: table/query
> >Bound column: 1
> >Row source: <I have a select that returns the desired records>
> >
> >In cboClient_AfterUpdate() I look at debug.print cboClient.Value and I see
> >the name.  I need the PK so I can construct the query for the next combo box.
> 
> You need ColumnCount = 2, Bound Column 1, ColumnWidths property
> 
> 0";1"
> 
> (or some other nonzero width for the name).
> 
> 
> -- 
> 
>              John W. Vinson [MVP]
> .
> 
0
Utf
2/20/2010 7:26:31 AM
On Sat, 20 Feb 2010 07:18:00 GMT, "new2access123 via AccessMonster.com"
<u58027@uwe> wrote:

>I see my error.  Left out the PK from the SELECT field list.  Thank ypu for
>the help.

<g> Yep... can't save what isn't there! Glad you got it working.
-- 

             John W. Vinson [MVP]
0
John
2/20/2010 8:24:48 PM
Reply:

Similar Artilces:

Size of drop box
Is there a way to change to font size of drop boxes for cells in Excel? For a Data Validation dropdown list, you can't change the font size. However, you can use programming to adjust the zoom setting when the cell is selected. There's some sample code here: http://www.contextures.com/xlDataVal08.html#Larger John Babcock wrote: > Is there a way to change to font size of drop boxes for cells in Excel? -- Debra Dalgleish Excel FAQ, Tips & Book List http://www.contextures.com/tiptech.html ...

Two Outlook 2000 boxes merge to one
Hi: User A: Left the Company Several weeks Ago. User B: Used User "A" email box until she got hired on a Perm basis. Issue: User B now has her own inbox but would like to have all of the 1500 hundred emails and folders in USER "A" in box transferred to her new in box. OBvioulsy she could simply forward these emails to her own box BUT I wanna know if there is another way to get the present info from USEr "A" inbox to transferred USer "B" in box? Can the two in boxes some how merge? Once this "merge" has taken place USER A in box ...

Cursor keys behaving differently
Instead of moving the selected cell box around they scroll the window around instead. It doesn't do this on other application such as Notepad or Word so I assume it's an Excel issue? Any ideas? Press ScrollLock key again. Cwatters wrote: > Instead of moving the selected cell box around they scroll the window around > instead. It doesn't do this on other application such as Notepad or Word so > I assume it's an Excel issue? Any ideas? > > > "Bob I" <birelan@yahoo.com> wrote in message news:uEDriroRKHA.4048@TK2MSFTNGP05.phx.gbl......

Tab key problems #2
I have a protected worksheet in Excel 2003. The arrow keys will move through the unlocked cells, but the Tab key will not. Is there some way to correct this problem? Marilyn Sounds like all cells are locked if the Tab key won't move. Did you select the cells to be unlocked and set them as such prior to protecting the worksheet? Gord Dibben Excel MVP On Tue, 15 Nov 2005 07:09:07 -0800, "Marilyn" <Marilyn@discussions.microsoft.com> wrote: >I have a protected worksheet in Excel 2003. The arrow keys will move through >the unlocked cells, but the Tab key will not...

Text boxes
When I open a new text box it always has 2 columns in it. How can I change it to just open with 1 box with no columns Thelma darling, what oh what version of Publisher are you using??? -- I am using Publisher 2000 Thelma wrote: > I am using Publisher 2000 What about them?! Was there supposed to be a question in there somewhere?! Sarah, Did you bother to read the thread? Of course not - it shows! May 2004 bring you a tinge of humanity and caring, as well as tolerance and intelligence. You're seriously lacking in all four areas. Merry Christmas, Mike Epona wrote: > Th...

text disapearing in a text box
I put a text box on a chart. After typing it in (it was a long text) I saved the chart I could still see all the text. After I saved it, I created a PDF. It was still fine. After I closed excel. The next time I opened the chart part of the text was gone. I tried to resize the text box, but part of the text was still gone. When I oringinally save the chart I didn't get an error message about the size and the pdf after the save showed all of the text. Thanks ...

Transparent text boxes
I have text boxes which have a fill color yet transparent center and then an image behind the text box. On the screen it shows up perfectly, yet when I print it the image is blocked. Any ideas? Thank You Publisher has issues with transparency. Create a rectangle the size of your text box, apply your transparency, right-click, save as picture, select the .png format, re-insert the saved image into your publication. -- Mary Sauer http://msauer.mvps.org/ "Sam@Postnet" <Sam@Postnet@discussions.microsoft.com> wrote in message news:2C9504A9-C26E-4025-8320-405ADE655DBC@mic...

how do I get a custom message box to open?
I have a form/subform where I need to have the event and date entered on the main form before information can be entered into the subform. How do I get a custom message box to pop up instead of the generic "You must enter a value in the ... field" when the event and date have not been entered? I think that the order I want to do things in is the following. Help with the actual VBA would be very much appreciated. - What event to use? - check to see if AtEventID is null - do I need this step? Because both the date and event fields are required, Access automatica...

Text cut off in Text Box. (Not a quantity issue)
Hello, I am having an issue with the text in a text box being cut off when I actually print the document. I have changed the internal margins of the text box, but I'm still having issues. The margin will appear, but it still cuts off part of my text. ("the is th") Any suggestions? During print preview the it isn't an issue. The text appears normal. Thanks in advance. ...

Print Dialog Box
Not sure if this is possible in excel but can you create a box which you then enter a code and from a seperate sheet all the data gets printed. At the moment I write a macro for each code Thanks You're Bunny??? Check your other post. AmyD wrote: > > Not sure if this is possible in excel but can you create a box which you then > enter a code and from a seperate sheet all the data gets printed. At the > moment I write a macro for each code > > Thanks -- Dave Peterson ...

Has anyone seen my FIND dialog box (Word 2007)?
My FIND dialog box in Word has disappear. When I invoke the FIND command (press Ctrl-F or select Find from the the Edit box, or from my toolbar), the FIND box does not appear anywhere on my screen. I've closed all windows and it doesn't seem to be hiding behind anything. FIND is working in all other applicaitons. Wondering if I've somehow disabled FIND functionality, or if the dialog is minimized somewhere that I can't see. Any ideas how to get my FIND dialog box back? Well, when you open the Find panel your cursor is in the box, so you could start typing some...

mail boxes per edb file and archive management questions
Hi... 1. How large can an edb file get and how many mail boxes can one hold? 2. I read somewhere that exchange can have a max of 4 edb files? 3. What are the best practises when an edb file reaches maximum size... how do you move messages in the edb file to the archive storage? /D This is dependent on the version of Exchange you are running. For example: Exch 2K3 Std Edition has a 75GB limit per edb/stm (the Exchange data store is made up of an .edb and .stm file) Exch 2K3 Ent Edition has no practical limit. How large you should allow your data store to become depends really on your ...

VS Tools
In the EstimateFreight sample there is a "GPConnObj.Init" is it I need to supply the same registration key like in GP "Tools >> Setup >> System >> Registration"? Thanks ...

In Word the shortcut keys to change from UC to LC is shift F3....
In Word the shortcut keys to change from UC to LC is shift F3, why not have the shortcut keys to do the same in Excel? Hi is this a question on how to change case in Excel, or a request for MS to implement the shift F3 short-cut, if it is the later then email them at mswish@microsoft.com with excel in the subject line and details of what you would like in the message body. if the former then reposting in the form of a question might receive an answer. -- Cheers JulieD check out www.hcts.net.au/tipsandtricks.htm ....well i'm working on it anyway "jdtrkohler" <jdtrkohl...

Returned Mail
Howsit Guys, I am running Kerio Mail server 6.1.1 and are having problems with all outgoing mail: MWEB is my hosting my mail spool and am using a telkom ADSL line to breakthrough to the internet.I recieve the following error message when attempting to send mail. <xxxxx@domain.co.za> (smtp.saix.net: 554 5.7.1 <servername.domain.local>:Helo Command rejected: AOL TOS - SAIX Ref:H434 - Blacklisted for Spam Trojan) Please assist. Ive tried to use smtp.dsl.telkomsa.net,i dont recieve any bounce backs but the mail just doesnt go through! Shot! On Mon, 28 Jun 2010 08:...

List box, Combo box
Is it possible to select an existing item in a drop down menu, such as list or combo box, and have it link to another sheet tab, for exampl sheet2 or sheet -- P-C-Surgeo ----------------------------------------------------------------------- P-C-Surgeon's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1477 View this thread: http://www.excelforum.com/showthread.php?threadid=26396 yes, it is possible. it involves writing a macro for that combobox o listbox -- icestationzbr ----------------------------------------------------------------------- icestationzbra&#...

Check Box #3
I am trying to add check boxes to a protected document that will be selected when I tab through the document. Does anyone know if the check boxes can be formatted to be activated in theis way. Right now, I have to select the check boxes with the mouse. Thanks you could try this solution that I came up with a while back. This is a copy of that post Another way is to use this technique of having a check column, and monitoring it with a worksheet selection change event. Add your code as needed. Rather than use a checkbox, I suggest just using a check column. So if we assume that the dat...

exchange OWA mzil boxes access rigths
Guys, hello to everyone, who will try you help or just to read this post. Here is my problem. I have started a new job, this company migrated exchange 2000 to 2003. OWA was not working I have modified some to the setting within the IIS; it works now, but......... When I open my mail box at the first time, it asks for password, after I put the password and I am seeing my mail box, I can simply change just the user name part, On the browser and get to entire company e-mail boxes without supplying a password. Looks real cool to be hones I can read everyone's e-mail. What is the way to have OW...

How to assign a hot key to an existing macro in word 2007?
I saw how to attach a key to a macro when starting to record a new macro. But how do I attach it after one is created and working? Word Menu (or Button)>Word Options>Customize>Keyboard shortcuts "Customize" and choose the "Macros" category nixonian wrote: > I saw how to attach a key to a macro when starting to record a new > macro. But how do I attach it after one is created and working? I finally found the command "Customize Keyboard" using "Search Commands" menu item. I still have not found it in the standard ribbon...

Custom entity with same display name as out of the box?
I tried to create a new entity "new_InvoiceDDI" with a display name of "Invoice" and it won't allow the display name to be the same as a "out of the box" entity. Why is this? Anyone know a way around it? CRM 4.0 Mark Hi Mark, There's no way around it except renaming the existing invoice entity to something else. One obvious reason is the Outlook Client. It uses the display names to show folders, but folders needs to have a unique name. The web client uses the display names as well, so how can a user differentiate between two entities having the...

shortcut keys for comments
Is there a shortcut key to add a comment. How about to edit a comment Sherry, I don't think there is a short cut key for it, but you could use a macro and assign it to a button or key. Have a look here for details http://www.contextures.com/xlcomments03.html -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 97 & 2000 ** remove news from my email address to reply by email ** "Sherry" <anonymous@discussions.microsoft.com> wrote ...

Key Product not being requignized for Office Product Standard Tri
Please help after I registered for free trial Office Project Standard it is not requignizing product key given to me ...

Function to return sound?
I have a file that is monitoring and trending external data. I have a type of animation that occurs based on the data (very simple graphics using fonts, colors and conditional formating). Similarly, I have tables that have cells changing colors to reflect the type of value in the cell based on a range criteria. Rather than using conditional formating to return a color or some traditional format, I want to know how to execute a MS sound, or in some way, launch a macro, etc., where a sound could be driven. Any MS sound would be fine. I just can think of a way similar to conditioinal formating, ...

XslTransform return Xml.InnerText
Hi, Getting crazy with the XslTransform Class. I'm trying to transform an xml string with an xsl string with the following code : 'Create the XslTransform object and load the stylesheet. Dim oXslXmlReader As XmlTextReader = New XmlTextReader(MyXslString, XmlNodeType.Document, Nothing) Dim oXslXslTransform As XslTransform = New XslTransform oXslXslTransform.Load(oXslXmlReader, Nothing, Nothing) 'Load the xml to transform. Dim OXmlReader As XmlTextReader = New XmlTextReader(MyXmlString, XmlNodeType.Document, Nothing) Dim xPathDoc As XPathDocument = New XPathDocument(OXmlReader, Xml...

One of the product keys is not valid
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Hi! I just installed the Office Mac Home and Student version in my MacBook and my husband tried the second product key on his IMac, but got a message saying the product key is not valid. We tried with the third key and it worked. The thing is I'm allowed to use the three of them but I can only use two. Of course, now we both have the software installed, but we still want access to the third key. We entered the numbers a couple of times, checking they were right. Any ideas? Thanks! Maria_O@officeformac.com wrote: &g...