Syntax error in query expression

  • Thread starter Thread starter Vernon
  • Start date Start date
V

Vernon

Good morning,

I am attempting to calculate the "Obl Fees" field of my
data entry form by multiplying the "LU_Type" and "Units"
fields of the same form. The only complications are that
the "LU_Type" field is a pull down menu referencing a
table called "tbl_LU_Type" and that the equation is
actually referencing a different column in the table than
what is shown ("LU_Type" is shown, but I am referencing
the "Fee Per Unit" column in my equation).

Using code editor, I have added the following line of
script to the after update fields of both the "LU_Type"
and "Units" fields:

Private Sub Units_AfterUpdate()
If Not IsNull(Me.[LU_Type]) And Not IsNull(Me.[Units]) Then
Me.[Obl Fees] = DFirst("Fee Per
Unit", "tbl_LU_Type", "LU_Type=" & Me.[LU_Type] & "") * Me.
[Units]

End If

"LU_Type" is the first field that gets data entered into
it. Everything goes well there. It is when I enter data
to the second field "Units" that I get the following
error: Run Time Error 3075. Syntax Error (Missing
Operator) in query expression 'first(Fee Per Unit)'.

If anyone could tell me what's going on and how to remedy
it, I would be greatly appreciative.

Thanks,
Kendra
 
Vernon said:
Good morning,

I am attempting to calculate the "Obl Fees" field of my
data entry form by multiplying the "LU_Type" and "Units"
fields of the same form. The only complications are that
the "LU_Type" field is a pull down menu referencing a
table called "tbl_LU_Type" and that the equation is
actually referencing a different column in the table than
what is shown ("LU_Type" is shown, but I am referencing
the "Fee Per Unit" column in my equation).

Using code editor, I have added the following line of
script to the after update fields of both the "LU_Type"
and "Units" fields:

Private Sub Units_AfterUpdate()
If Not IsNull(Me.[LU_Type]) And Not IsNull(Me.[Units]) Then
Me.[Obl Fees] = DFirst("Fee Per
Unit", "tbl_LU_Type", "LU_Type=" & Me.[LU_Type] & "") * Me.
[Units]

End If

"LU_Type" is the first field that gets data entered into
it. Everything goes well there. It is when I enter data
to the second field "Units" that I get the following
error: Run Time Error 3075. Syntax Error (Missing
Operator) in query expression 'first(Fee Per Unit)'.

If anyone could tell me what's going on and how to remedy
it, I would be greatly appreciative.

Thanks,
Kendra
Hi,

Well ... no certainty here, but the first thing I'd try is ...

DFirst("[tbl_LU_Type]![Fee Per Unit]", "tbl_LU_Type", "LU_Type=" &
Me.[LU_Type] & "")

Spaces in field names can cause a variety of havoc all their own :-)

From a first look, that's the only sensible suggestion I can make.

HTH

MFK.
 
Back
Top