Event to use selection from Combo Box to update text box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Form FaxTransmittal uses tblTransmittal Table

Table ---> tblTransmittal
combo box -->From_Name --->SELECT [From_Name], [From_Phone], [From_Fax] FROM
[tblProjectDirectoryFrom] ORDER BY [From_Name]

When selecting a name from Combo Box From_Name, I would like the From_Phone
and From_Fax Textbox to automatically update.

I have tried these following codes and the one from the Northwind example
and nothing has worked.

Private Sub From_Name_AfterUpdate()
tblTransmittal_From_Name = tblProjectDirectoryFrom_From_Name
tblTransmittal_From_Phone = tblProjectDirectoryFrom_From_Phone
tblTransmittal_From_Fax = tblProjectDirectoryFrom_From_Fax
End Sub

and

Private Sub cboFromName_AfterUpdate()
If Not IsNull(Me!cboFromName) Then
Me!cboFromName = Me!cboFromName.Column(1)
Me!FromPhoneTextbox = Me!cboFromName.Column(2)
Me!FromFaxTextbox = Me!cboFromName.Column(3)
End If

End Sub

Please help.
 
Michelle said:
Form FaxTransmittal uses tblTransmittal Table

Table ---> tblTransmittal
combo box -->From_Name --->SELECT [From_Name], [From_Phone], [From_Fax] FROM
[tblProjectDirectoryFrom] ORDER BY [From_Name]

When selecting a name from Combo Box From_Name, I would like the From_Phone
and From_Fax Textbox to automatically update.

I have tried these following codes and the one from the Northwind example
and nothing has worked.

Private Sub From_Name_AfterUpdate()
tblTransmittal_From_Name = tblProjectDirectoryFrom_From_Name
tblTransmittal_From_Phone = tblProjectDirectoryFrom_From_Phone
tblTransmittal_From_Fax = tblProjectDirectoryFrom_From_Fax
End Sub

and

Private Sub cboFromName_AfterUpdate()
If Not IsNull(Me!cboFromName) Then
Me!cboFromName = Me!cboFromName.Column(1)
Me!FromPhoneTextbox = Me!cboFromName.Column(2)
Me!FromFaxTextbox = Me!cboFromName.Column(3)
End If

End Sub


The Column property is zero based.

This should do what you want:

Private Sub cboFromName_AfterUpdate()
If Not IsNull(Me!cboFromName) Then
Me!FromPhoneTextbox = Me!cboFromName.Column(1)
Me!FromFaxTextbox = Me!cboFromName.Column(2)
End If
 
Marshall Barton said:
Michelle said:
Form FaxTransmittal uses tblTransmittal Table

Table ---> tblTransmittal
combo box -->From_Name --->SELECT [From_Name], [From_Phone], [From_Fax] FROM
[tblProjectDirectoryFrom] ORDER BY [From_Name]

When selecting a name from Combo Box From_Name, I would like the From_Phone
and From_Fax Textbox to automatically update.

I have tried these following codes and the one from the Northwind example
and nothing has worked.

Private Sub From_Name_AfterUpdate()
tblTransmittal_From_Name = tblProjectDirectoryFrom_From_Name
tblTransmittal_From_Phone = tblProjectDirectoryFrom_From_Phone
tblTransmittal_From_Fax = tblProjectDirectoryFrom_From_Fax
End Sub

and

Private Sub cboFromName_AfterUpdate()
If Not IsNull(Me!cboFromName) Then
Me!cboFromName = Me!cboFromName.Column(1)
Me!FromPhoneTextbox = Me!cboFromName.Column(2)
Me!FromFaxTextbox = Me!cboFromName.Column(3)
End If

End Sub


The Column property is zero based.

This should do what you want:

Private Sub cboFromName_AfterUpdate()
If Not IsNull(Me!cboFromName) Then
Me!FromPhoneTextbox = Me!cboFromName.Column(1)
Me!FromFaxTextbox = Me!cboFromName.Column(2)
End If

Marsh,
I did as you have noted above. Now each Record show the same Value for my
From_Name Combo Box. How do I correct this? Also, will this change for
Access 2003.

Thanks,

Michelle
 
Michelle said:
Form FaxTransmittal uses tblTransmittal Table

Table ---> tblTransmittal
combo box -->From_Name --->SELECT [From_Name], [From_Phone], [From_Fax] FROM
[tblProjectDirectoryFrom] ORDER BY [From_Name]

When selecting a name from Combo Box From_Name, I would like the From_Phone
and From_Fax Textbox to automatically update.

I have tried these following codes and the one from the Northwind example
and nothing has worked.

Private Sub From_Name_AfterUpdate()
tblTransmittal_From_Name = tblProjectDirectoryFrom_From_Name
tblTransmittal_From_Phone = tblProjectDirectoryFrom_From_Phone
tblTransmittal_From_Fax = tblProjectDirectoryFrom_From_Fax
End Sub

and

Private Sub cboFromName_AfterUpdate()
If Not IsNull(Me!cboFromName) Then
Me!cboFromName = Me!cboFromName.Column(1)
Me!FromPhoneTextbox = Me!cboFromName.Column(2)
Me!FromFaxTextbox = Me!cboFromName.Column(3)
End If

End Sub
Marshall Barton said:
The Column property is zero based.

This should do what you want:

Private Sub cboFromName_AfterUpdate()
If Not IsNull(Me!cboFromName) Then
Me!FromPhoneTextbox = Me!cboFromName.Column(1)
Me!FromFaxTextbox = Me!cboFromName.Column(2)
End If
Michelle said:
I did as you have noted above. Now each Record show the same Value for my
From_Name Combo Box. How do I correct this? Also, will this change for
Access 2003.


You can add the same code to the form's Current event,
except that it will still show the same values if your form
is displayed in continuous or datasheet view.

Let's try an an alternative approach that should work in all
cases. Get rid of those four lines of code and set the
FromPhoneTextbox text box's control source expression to:
=cboFromName.Column(1)
and the FromFaxTextbox to:
=cboFromName.Column(2)
 
Back
Top