Auto-Populate Info in Textbox when a selection is made in Combobox

C

cwAFcontractor

I'm new to this Access Database world and i'm tasked with creating a database
to keep track of the inventory in my shop. I'm creating a form that will
imput information into a table. On this Form there is a section at the bottom
where you can put the Authorizing information. There is a combo box which you
can select the authorizing party (only two as of right now), and two text
boxs (one is email of AP and the other is Phone of AP). What i would like to
happen is when the AP is selected in the combo box i would like the
corrisponding email and phone be imput into the corresponding text boxes.

I have no idea how to start this. I have tried reading a few threads and
books but can't find exactly what i'm looking for. I have tried to do the
afterupdate wizard when you used more then one column in the combo box wizard
and don't think i did it right because it messed up the combo box and only
gave one option with all the info on one line. I also tried writing a vb code
to imput the information but dont think i did that right either because
nothing happened when i selected the option in the combo box. As long as i
have only one column in the combo box it works fine for the combo box but i
can't get the info populated. below is the vb code that i used but didnt work.


Private Sub enterdata_AfterUpdate()

Set Number = Form_COTSRequest.CORPhoneNumber
Set Email = Form_COTSRequest.COREmail

If CmbCORName = "fn ln" Then
Number = "XXX-225-XXX9"
Email = "[email protected]"
ElseIf CmbCORName = "MSgt fn Ln" Then
Number = "XX-225-XXX8"
Email = "[email protected]"
End If
End Sub
 
G

Graham Mandeno

Hi cwAFcontractor

A combo box can have many columns. The only column that is visible when the
box is not dropped down is the first one with non-zero width. However, the
other columns are available via the Column property.

For example, say you have a combo box with these properties:
Name: cboAP
ColumnCount: 4
BoundColumn: 1
ColumnWidths: 0cm; ;0cm; 0cm
(notice the width of the second column is blank, so it will use all the
available space)
RowSource: Select AP_ID, AP_Name, AP_Phone, AP_Email
from AuthorizingParties order by AP_Name ;

Now, the AP_Phone and AP_Email columns are in the combo box but they are
hidden (width=0).

You can now place two textboxes on your form:
Name: txtAP_Phone
ControlSource: cboAP.Column(2)
and
Name: txtAP_Email
ControlSource: cboAP.Column(3)

These will display those fields for the currently selected customer.

Note that the column number starts counting from zero. Column(2) is the
third column.
 
C

cwAFcontractor via AccessMonster.com

Thanks that worked great.

Graham said:
Hi cwAFcontractor

A combo box can have many columns. The only column that is visible when the
box is not dropped down is the first one with non-zero width. However, the
 
Top