Jul 21 2005, 02:12 PM
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,
Jul 21 2005, 03:00 PM
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:
comboB = Me.B_ID
comboC = Me.C_ID
The above code is assuming that the comboboxes are unbound.
Jul 21 2005, 10:37 PM
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,
Jul 22 2005, 12:09 AM
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.