compile error - expected expression

J

JohnLute

I'm trying something new and not sure if I'm on the right track. I have an
unbound text box on a form and I'm trying a calculation in the AfterUpdate
event:

Private Sub BlankArea_AfterUpdate()
If (Me!BlankLengthUOM = "in.") Then
([BlankLength]*[BlankWidth])/144
End If
ElseIf Me!BlankLengthUOM = "mm" _
Then
([BlankLength]*[BlankWidth])*92903.04
End If

End Sub

The debugger is pointing to the "*" in both lines.

Can anyone straighten me out with this? Am I on the right track at all?

Thanks!
 
D

Dennis

You are performaing a calculation but not assigning it anywhere and also
ending the IF before the Else
Try something like this

Private Sub BlankArea_AfterUpdate()
If Me!BlankLengthUOM = "in." Then
Me!SomeBoxName = ([BlankLength]*[BlankWidth])/144
Else
If Me!BlankLengthUOM = "mm" Then
Me!SomeBoxName = ([BlankLength]*[BlankWidth])*92903.04
End If
End If
End Sub
 
J

JohnLute

Thanks, Dennis!

I plugged this in:
Private Sub BlankArea_AfterUpdate()
If Me!BlankLengthUOM = "in." Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) / 144
Else
If Me!BlankLengthUOM = "mm" Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) * 92903.04
End If
End If
End Sub

The debugger doesn't highlight any problems and I'm not getting any error
messages however the unbound text box [BlankArea] displays a null value.

Any ideas?

Thanks for your help!

--
www.Marzetti.com


Dennis said:
You are performaing a calculation but not assigning it anywhere and also
ending the IF before the Else
Try something like this

Private Sub BlankArea_AfterUpdate()
If Me!BlankLengthUOM = "in." Then
Me!SomeBoxName = ([BlankLength]*[BlankWidth])/144
Else
If Me!BlankLengthUOM = "mm" Then
Me!SomeBoxName = ([BlankLength]*[BlankWidth])*92903.04
End If
End If
End Sub


JohnLute said:
I'm trying something new and not sure if I'm on the right track. I have an
unbound text box on a form and I'm trying a calculation in the AfterUpdate
event:

Private Sub BlankArea_AfterUpdate()
If (Me!BlankLengthUOM = "in.") Then
([BlankLength]*[BlankWidth])/144
End If
ElseIf Me!BlankLengthUOM = "mm" _
Then
([BlankLength]*[BlankWidth])*92903.04
End If

End Sub

The debugger is pointing to the "*" in both lines.

Can anyone straighten me out with this? Am I on the right track at all?

Thanks!
 
D

Dennis

According to your code, you are typing something into the blank area field
which will fire the after update event, but then you are overwriting it
straight away with your calculation. You should have the code in the after
update event of the BlankLengthUOM, BlankLength and BlankWidth fields instead.
Alternatively you could set the control source property of the BlankArea
field to
=IIF(BlankLengthUOM = "in.",([BlankLength] * [BlankWidth]) /
144,IIF(BlankLengthUOM = "mm",([BlankLength] * [BlankWidth]) * 92903.04),"")

JohnLute said:
Thanks, Dennis!

I plugged this in:
Private Sub BlankArea_AfterUpdate()
If Me!BlankLengthUOM = "in." Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) / 144
Else
If Me!BlankLengthUOM = "mm" Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) * 92903.04
End If
End If
End Sub

The debugger doesn't highlight any problems and I'm not getting any error
messages however the unbound text box [BlankArea] displays a null value.

Any ideas?

Thanks for your help!

--
www.Marzetti.com


Dennis said:
You are performaing a calculation but not assigning it anywhere and also
ending the IF before the Else
Try something like this

Private Sub BlankArea_AfterUpdate()
If Me!BlankLengthUOM = "in." Then
Me!SomeBoxName = ([BlankLength]*[BlankWidth])/144
Else
If Me!BlankLengthUOM = "mm" Then
Me!SomeBoxName = ([BlankLength]*[BlankWidth])*92903.04
End If
End If
End Sub


JohnLute said:
I'm trying something new and not sure if I'm on the right track. I have an
unbound text box on a form and I'm trying a calculation in the AfterUpdate
event:

Private Sub BlankArea_AfterUpdate()
If (Me!BlankLengthUOM = "in.") Then
([BlankLength]*[BlankWidth])/144
End If
ElseIf Me!BlankLengthUOM = "mm" _
Then
([BlankLength]*[BlankWidth])*92903.04
End If

End Sub

The debugger is pointing to the "*" in both lines.

Can anyone straighten me out with this? Am I on the right track at all?

Thanks!
 
J

JohnLute

Well, I'm being a bit thick!

Thanks for clearing my head. I actually opted for this:
Private Sub BlankLengthUOM_AfterUpdate()
If Me!BlankLengthUOM = "in." Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) / 144
Else
If Me!BlankLengthUOM = "mm" Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) *
0.000010763910417
End If
End If
End Sub

Private Sub BlankWidthUOM_AfterUpdate()
If Me!BlankWidthUOM = "in." Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) / 144
Else
If Me!BlankWidthUOM = "mm" Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) *
0.000010763910417
End If
End If
End Sub

This reveals another challenge. I need to assure that [BlankLengthUOM] and
[BlankWidthUOM] will have the same value. Both need to be either "in." or
"mm". I suppose I can plug something into the AfterUpdate events for this but
I'm not sure how to approach that.

If (Me!BlankLengthUOM = "in.") Then

I'm lost after that. Any ideas?

--
www.Marzetti.com


Dennis said:
According to your code, you are typing something into the blank area field
which will fire the after update event, but then you are overwriting it
straight away with your calculation. You should have the code in the after
update event of the BlankLengthUOM, BlankLength and BlankWidth fields instead.
Alternatively you could set the control source property of the BlankArea
field to
=IIF(BlankLengthUOM = "in.",([BlankLength] * [BlankWidth]) /
144,IIF(BlankLengthUOM = "mm",([BlankLength] * [BlankWidth]) * 92903.04),"")

JohnLute said:
Thanks, Dennis!

I plugged this in:
Private Sub BlankArea_AfterUpdate()
If Me!BlankLengthUOM = "in." Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) / 144
Else
If Me!BlankLengthUOM = "mm" Then
Me!BlankArea = ([BlankLength] * [BlankWidth]) * 92903.04
End If
End If
End Sub

The debugger doesn't highlight any problems and I'm not getting any error
messages however the unbound text box [BlankArea] displays a null value.

Any ideas?

Thanks for your help!

--
www.Marzetti.com


Dennis said:
You are performaing a calculation but not assigning it anywhere and also
ending the IF before the Else
Try something like this

Private Sub BlankArea_AfterUpdate()
If Me!BlankLengthUOM = "in." Then
Me!SomeBoxName = ([BlankLength]*[BlankWidth])/144
Else
If Me!BlankLengthUOM = "mm" Then
Me!SomeBoxName = ([BlankLength]*[BlankWidth])*92903.04
End If
End If
End Sub


:

I'm trying something new and not sure if I'm on the right track. I have an
unbound text box on a form and I'm trying a calculation in the AfterUpdate
event:

Private Sub BlankArea_AfterUpdate()
If (Me!BlankLengthUOM = "in.") Then
([BlankLength]*[BlankWidth])/144
End If
ElseIf Me!BlankLengthUOM = "mm" _
Then
([BlankLength]*[BlankWidth])*92903.04
End If

End Sub

The debugger is pointing to the "*" in both lines.

Can anyone straighten me out with this? Am I on the right track at all?

Thanks!
 
Top