AfterUpdate VB If statement

  • Thread starter Thread starter ArneGolf
  • Start date Start date
A

ArneGolf

I am having a problem with this code:
Private Sub Cart_Shed_Number_AfterUpdate()
If (Me.Cart_Shed_Number) = "NA" And (Me.Cart_Type) = "NA" Then
Me.Cart_Shed_Fee = "0"
ElseIf (Me.Cart_Shed_Number) >= "A" And (Me.Cart_Type) = "Gas" Then
Me.Cart_Shed_Fee = "10"
ElseIf (Me.Cart_Shed_Number) >= "A" And (Me.Cart_Type) = "Electric" Then
Me.Cart_Shed_Fee = "20"
End If
End Sub
I want it to auto populate a "cart shed fee" field on a form depending on
the answers to the "cart shed number and cart type" fields.
 
I am having a problem with this code:
Private Sub Cart_Shed_Number_AfterUpdate()
If (Me.Cart_Shed_Number) = "NA" And (Me.Cart_Type) = "NA" Then
Me.Cart_Shed_Fee = "0"
ElseIf (Me.Cart_Shed_Number) >= "A" And (Me.Cart_Type) = "Gas" Then
Me.Cart_Shed_Fee = "10"
ElseIf (Me.Cart_Shed_Number) >= "A" And (Me.Cart_Type) = "Electric" Then
Me.Cart_Shed_Fee = "20"
End If
End Sub
I want it to auto populate a "cart shed fee" field on a form depending on
the answers to the "cart shed number and cart type" fields.

And the problem is...? You didn't say.

What's the datatype of the Cart_Shed_Fee field in your table? I presume that
(despite its name) the Cart_Shed_Number is Text? Has the Cart_Type control
already been filled in when you select a value in Cart_Shed_Number?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Run Macro If Cell have "x" value 0
If Else Statement in VBA 5
Problem with find 1
Option Group and If Statement 2
If Statement 4
If Statement 7
Compile Error: Else without IF 5
AfterUpdate event procedure 5

Back
Top