Need VB help for field in form

V

Vernon

Good afternoon,

I am attempting to make my "Obl Fees" be a calculated
value received by multiplying the "Units" and "LU_Type"
fields. The values in the "LU_Type" fields are from a
pull down menu (linked table) and I am referencing a
different column within the table. I recieved help on
this earlier, but my code is still popping up
an "expected: end" error and when I try to enter data into
the form, it pops up a syntax error when I get to
the "LU_Type" field, the first of the modified fields.

I checked that I spelt all of the fields correctly. Could
someone who knows VB well please read this and tell me
what I've done wrong (I am hoping that I've just made a
typo and have too little VB experience to see it).

Here is the string of code:

Private Sub LU_Type_BeforeUpdate(Cancel As Integer)
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

End Sub

Thanks,
Kendra
 
D

Dirk Goldgar

Vernon said:
Good afternoon,

I am attempting to make my "Obl Fees" be a calculated
value received by multiplying the "Units" and "LU_Type"
fields. The values in the "LU_Type" fields are from a
pull down menu (linked table) and I am referencing a
different column within the table. I recieved help on
this earlier, but my code is still popping up
an "expected: end" error and when I try to enter data into
the form, it pops up a syntax error when I get to
the "LU_Type" field, the first of the modified fields.

I checked that I spelt all of the fields correctly. Could
someone who knows VB well please read this and tell me
what I've done wrong (I am hoping that I've just made a
typo and have too little VB experience to see it).

Here is the string of code:

Private Sub LU_Type_BeforeUpdate(Cancel As Integer)
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

End Sub

Thanks,
Kendra

The only thing that stands out for me as an error-raiser is that you appear
to be missing the dot (.) between "Me" and "[Units]" at the end of this
statement:
Me.[Obl Fees] = DFirst("Fee Per
Unit", "tbl_LU_Type","LU_Type=" & Me.[LU_Type]&"") * Me
[Units]

I would be using the control's AfterUpdate event for this, rather than its
BeforeUpdate event, since your purpose is not pre-update validation but
rather post-update calculation. And I don't see why you are appending "" to
Me.[LU_Type] in the criterion argument for the DFirst function. But neither
of those should be causing an actual error, so far as I can see.
 

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

Top