UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Combo box default value based on other value    
 
   
manojtjain
post Jul 21 2005, 02:12 PM
Post #1

New Member
Posts: 2



Hi! All,
I have a few linked tables in Access.
Suppose Table A has fields A.ID A.B_ID, A.C_ID, A.NAME, A.ADDRESS
Table B has B.ID, B.NAME and Table C has C.ID, C.NAME
As you can make out, A.B_ID is always from B.ID and A.C_ID is alawys from C.ID
Now in the Access Form to list all the data in Table A, I display A.B_ID and corresponding B.NAME, and A.C_ID and C.NAME.
A.B_ID and A.C_ID are non-editable text boxes.
B.NAME and C.NAME are as combo boxes, so user can select particular name (as no one wants to memorize the codes). When a particular B.NAME is selected, A.B_ID text box is automatically updated with corresponding value. This is saved in the database when the record is saved.
Now the problem is when we display the record, it shows the ID in A.B_ID and A.C_ID textboxes, but how do I select the corresponding names in the B.NAME and C.NAME combo boxes?

Thanx in advance,
Manoj.
Go to the top of the page
 
+
b0b1
post Jul 21 2005, 03:00 PM
Post #2

UtterAccess Guru
Posts: 932
From: South Africa



Hi

Welcome to UA

I would personally just have the combo box display the name by setting the comboboxes control source to the B_ID and C_ID respectively, unless of course you particularly want to display the _ID fields.

To accomplish what you have asked, given the way you have set it up, in the forms OnCurrent event you would put the following code:

CODE
comboB = Me.B_ID
comboC = Me.C_ID


The above code is assuming that the comboboxes are unbound.

HTH
Go to the top of the page
 
+
manojtjain
post Jul 21 2005, 10:37 PM
Post #3

New Member
Posts: 2



The first suggestion worked perfect, I set the Control Source of the combo boxes to respective IDs.
I am still displaying the IDs in a text box separately, just for info, but they are locked fields, so that it can be changed only thru' combo box.
Thx for the quick help,
Manoj.
Go to the top of the page
 
+
b0b1
post Jul 22 2005, 12:09 AM
Post #4

UtterAccess Guru
Posts: 932
From: South Africa



A pleasure.

You can also refer to the columns of a combo box by using =ComboBoxName.Columns(0), this will automatically make it read only.

Just remember that 0 is the first column, 1 is the second column and so on.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 18th June 2013 - 07:22 PM