Code Stops

  • Thread starter Thread starter Bob Line
  • Start date Start date
B

Bob Line

Hi the following code stops at (If Me.[Policy Holders Name] = "Surrey" Then)
when it should run on, if you take the first 2 lines of code out it works
fine so how do you join the 2 pieces of code together.

Any help would me appreciated.

Thanks Bob


Private Sub Combo229_AfterUpdate()
Me.[Policy Number] = [Combo229].Column(1)
Me.[InsuranceCompany] = [Combo229].Column(2)
If Me.[Policy Holders Name] = "Surrey" Then
Me.[CfAttnOf] = "C/O David"
Me.[CfAddress] = "Road"
Me.[CfAddress1] = "Lane"
Me.[CfCity] = "Ep"
Me.CfCounty = "Surr"
Me.CfPostalCode = "GP11"
Me.[ClaimCode].SetFocus

ElseIf Me.[Policy Holders Name] = "" Then

Me.[Employer].SetFocus

End If

End Sub
 
Bob said:
Hi the following code stops at (If Me.[Policy Holders Name] = "Surrey" Then)
when it should run on, if you take the first 2 lines of code out it works
fine so how do you join the 2 pieces of code together.

Any help would me appreciated.

Thanks Bob


Private Sub Combo229_AfterUpdate()
Me.[Policy Number] = [Combo229].Column(1)
Me.[InsuranceCompany] = [Combo229].Column(2)
If Me.[Policy Holders Name] = "Surrey" Then
Me.[CfAttnOf] = "C/O David"
Me.[CfAddress] = "Road"
Me.[CfAddress1] = "Lane"
Me.[CfCity] = "Ep"
Me.CfCounty = "Surr"
Me.CfPostalCode = "GP11"
Me.[ClaimCode].SetFocus

ElseIf Me.[Policy Holders Name] = "" Then

Me.[Employer].SetFocus

End If

End Sub
Add some error checking in your subroutine and VBA will tell what is wrong.
Does your combo box have 3 columns in it? Combo and List boxes are base 0,
which means the 1st column Column(0).

Private Sub Combo229_AfterUpdate()

On Error GoTo Err_Combo229_AfterUpdate

Me.[Policy Number] = [Combo229].Column(1)
Me.[InsuranceCompany] = [Combo229].Column(2)
If Me.[Policy Holders Name] = "Surrey" Then
Me.[CfAttnOf] = "C/O David"
Me.[CfAddress] = "Road"
Me.[CfAddress1] = "Lane"
Me.[CfCity] = "Ep"
Me.CfCounty = "Surr"
Me.CfPostalCode = "GP11"
Me.[ClaimCode].SetFocus

ElseIf Me.[Policy Holders Name] = "" Then

Me.[Employer].SetFocus

End If



Exit_Combo229_AfterUpdate:
Exit Sub

Err_Combo229_AfterUpdate:
MsgBox Error$
Resume Exit_Combo229_AfterUpdate

End Sub

Ron
 
Ron I have put in the error coding as you suggested, it still only runs the
first 2 lines of code and then stops. It doesn't come up with any error
messages but fails to enter the name and address as required.

Yes the combo box does have 3 columns in it.

Regards Bob

Ronald W. Roberts said:
Bob said:
Hi the following code stops at (If Me.[Policy Holders Name] = "Surrey" Then)
when it should run on, if you take the first 2 lines of code out it works
fine so how do you join the 2 pieces of code together.

Any help would me appreciated.

Thanks Bob


Private Sub Combo229_AfterUpdate()
Me.[Policy Number] = [Combo229].Column(1)
Me.[InsuranceCompany] = [Combo229].Column(2)
If Me.[Policy Holders Name] = "Surrey" Then
Me.[CfAttnOf] = "C/O David"
Me.[CfAddress] = "Road"
Me.[CfAddress1] = "Lane"
Me.[CfCity] = "Ep"
Me.CfCounty = "Surr"
Me.CfPostalCode = "GP11"
Me.[ClaimCode].SetFocus

ElseIf Me.[Policy Holders Name] = "" Then

Me.[Employer].SetFocus

End If

End Sub
Add some error checking in your subroutine and VBA will tell what is wrong.
Does your combo box have 3 columns in it? Combo and List boxes are base 0,
which means the 1st column Column(0).

Private Sub Combo229_AfterUpdate()

On Error GoTo Err_Combo229_AfterUpdate

Me.[Policy Number] = [Combo229].Column(1)
Me.[InsuranceCompany] = [Combo229].Column(2)
If Me.[Policy Holders Name] = "Surrey" Then
Me.[CfAttnOf] = "C/O David"
Me.[CfAddress] = "Road"
Me.[CfAddress1] = "Lane"
Me.[CfCity] = "Ep"
Me.CfCounty = "Surr"
Me.CfPostalCode = "GP11"
Me.[ClaimCode].SetFocus

ElseIf Me.[Policy Holders Name] = "" Then

Me.[Employer].SetFocus

End If



Exit_Combo229_AfterUpdate:
Exit Sub

Err_Combo229_AfterUpdate:
MsgBox Error$
Resume Exit_Combo229_AfterUpdate

End Sub

Ron

--
Ronald W. Roberts
Roberts Communication
(e-mail address removed)
To reply remove "_at_robcom_dot_com"
 
Back
Top