Rob_Jones101
Member
- Local time
- Today, 11:32
- Joined
- Aug 8, 2019
- Messages
- 41
Hi
I have a combo box with two options in it, Site or Yard. When I click site I want it to pull the address from another combo box and when I click Yard I want it to pull it from a different combo box. I have the code below but it dosen't seem to work properly. I think my IF statement might be faulty but i'm not sure. Any help would be appreciated.
Private Sub Cbodeladdress_AfterUpdate()
On Error GoTo Cbodeladdress_AfterUpdate_Error
If me.Cbodeladdress = "Yard" Then
Me.Txtaddress = Me.Cbodeladdress.Column(1)
Me.Txttown = Me.Cbodeladdress.Column(2)
Me.Txtcounty = Me.Cbodeladdress.Column(3)
Me.Txtpostcode = Me.Cbodeladdress.Column(4)
Me.Txtsitecontact = Me.Cbodeladdress.Column(5)
Else
if me.Cbodeladdress = "Site" Then
Me.Txtaddress = Me.Site.Column(1)
Me.Txttown = Me.Site.Column(2)
Me.Txtcounty = Me.Site.Column(3)
Me.Txtpostcode = Me.Site.Column(4)
Me.Txtsitecontact = Me.Site.Column(5)
End If
Cbodeladdress_AfterUpdate_Exit:
Exit Sub
Cbodeladdress_AfterUpdate_Error:
Select Case Err
Case Else
MsgBox Err & "-" & Error$, vbCritical + vbOKOnly, "Error in module Cbodeladdress_AfterUpdate"
Resume Cbodeladdress_AfterUpdate_Exit
End Select
End Sub
I have a combo box with two options in it, Site or Yard. When I click site I want it to pull the address from another combo box and when I click Yard I want it to pull it from a different combo box. I have the code below but it dosen't seem to work properly. I think my IF statement might be faulty but i'm not sure. Any help would be appreciated.
Private Sub Cbodeladdress_AfterUpdate()
On Error GoTo Cbodeladdress_AfterUpdate_Error
If me.Cbodeladdress = "Yard" Then
Me.Txtaddress = Me.Cbodeladdress.Column(1)
Me.Txttown = Me.Cbodeladdress.Column(2)
Me.Txtcounty = Me.Cbodeladdress.Column(3)
Me.Txtpostcode = Me.Cbodeladdress.Column(4)
Me.Txtsitecontact = Me.Cbodeladdress.Column(5)
Else
if me.Cbodeladdress = "Site" Then
Me.Txtaddress = Me.Site.Column(1)
Me.Txttown = Me.Site.Column(2)
Me.Txtcounty = Me.Site.Column(3)
Me.Txtpostcode = Me.Site.Column(4)
Me.Txtsitecontact = Me.Site.Column(5)
End If
Cbodeladdress_AfterUpdate_Exit:
Exit Sub
Cbodeladdress_AfterUpdate_Error:
Select Case Err
Case Else
MsgBox Err & "-" & Error$, vbCritical + vbOKOnly, "Error in module Cbodeladdress_AfterUpdate"
Resume Cbodeladdress_AfterUpdate_Exit
End Select
End Sub