Error 2447 problem

jojo86

Registered User.
Local time
Today, 18:23
Joined
Mar 7, 2007
Messages
80
Hi guys

I have a piece of code that words out an area of land that is available to build on from its full value, using the following code:

Private Sub DT_PERCENT_AfterUpdate()
Dim fMultiply As Integer
If SITE_AREA_FY > 0 And DT_PERCENT > 0 Then
fMultiply = SITE_AREA_FY * DT_PERCENT
NEW_SITE_AREA = fMultiply
Else
End If
End Sub

So for example, if the SITE_AREA_FY is 5 acres and the DT_PERCENT is 50% then NEW_SITE_AREA should equal 2.5.
However, error 2447 'there is an invalid use of the . (dot) or ! operator or invalid parentheses' keeps popping up and I don't know why. The line in red is the 'invalid' code line.

Only thing I thought of was that DT_PERCENT (which gets pulled from a different table) is formatted as a percent. I tried changing it, but it still does the same error. Also, NEW_SITE_AREA is a unbound field because of it being a calculated field so I am not sure if it is that either.

I hope someone can help me, I would very much appreciate it!
 
Assuming these are the names of your controls on your form:

Private Sub DT_PERCENT_AfterUpdate()
Dim fMultiply As Integer
If SITE_AREA_FY.Value > 0 And DT_PERCENT.Value > 0 Then
fMultiply = SITE_AREA_FY.Value * DT_PERCENT.Value
NEW_SITE_AREA.Value = fMultiply
Else
End If
End Sub
 
Thanks for the post back.

I have just tried what you have suggested and, unfortunately, it still creates and error on the same line. And yes, they are the control names.
 
JoJo,

I'm kinda thinking you're getting the ".dot()" notation error because you're not referencing the controls correctly on the form (just a guess). Try this and see if it works....
Code:
Private Sub DT_PERCENT_AfterUpdate()
Dim fMultiply As Integer
  If me.SITE_AREA_FY > 0 And me.DT_PERCENT > 0 Then
    fMultiply = me.SITE_AREA_FY * me.DT_PERCENT
    me.NEW_SITE_AREA = fMultiply
  Else[b] <----[/b][color=red]you don't need this[/color]
  End If
End Sub
I don't think you need any ".Value" notations anywhere either.
 
Last edited:
Yeah you can use the Me.ControlName, but ControlName.Value should produce the same effect.
 
I have tried both suggestions and it still comes up with the error.

All I want to do is let the user pick a percentage in a drop down menu and then have them click a button for it to multiply what they have chosen by the site area (which is pulled from a different form by the way) to create a new site area value. Anyone got any different ideas instead of what I am doing?

DT_PERCENT is the combo box for percentages - 100, 80, 60, 20, 0 (these are stored as 1, 0.8, 0.6, 0.4, 0.2, 0 in the table but are formated to be percents).
SITE_AREA_FY is the site area value that is pulled from another form .
NEW_SITE_AREA is the box I would like the new site area value to show in.

Thanks for everyone's help :)
 
Hi,

If you are trying to multiply an Integer with a decimal or fraction, you can't.

Dim the variable to Single or Double.

Hi guys

I have a piece of code that words out an area of land that is available to build on from its full value, using the following code:

Private Sub DT_PERCENT_AfterUpdate()
Dim fMultiply As Integer
If SITE_AREA_FY > 0 And DT_PERCENT > 0 Then
fMultiply = SITE_AREA_FY * DT_PERCENT
NEW_SITE_AREA = fMultiply
Else
End If
End Sub

So for example, if the SITE_AREA_FY is 5 acres and the DT_PERCENT is 50% then NEW_SITE_AREA should equal 2.5.
However, error 2447 'there is an invalid use of the . (dot) or ! operator or invalid parentheses' keeps popping up and I don't know why. The line in red is the 'invalid' code line.

Only thing I thought of was that DT_PERCENT (which gets pulled from a different table) is formatted as a percent. I tried changing it, but it still does the same error. Also, NEW_SITE_AREA is a unbound field because of it being a calculated field so I am not sure if it is that either.

I hope someone can help me, I would very much appreciate it!
 
You are a complete genius! Thank you so much!

:D
 
This is an interesting area. I had similar problem some time ago and fixed it by using double rather than integer. Many people don't initially realise that integer only allows a whole number and will fail when it tries to evaluate a fraction or decimal.

Technically an integer takes less memory but unless memory is a real issues I now use double or long where there is any doubt.

Thanks Uncle Joe for picking this one up. It certainly brought back memories of me pulling my hair out (what little I have left) over similar problems. By the way I am in Singapore for a couple of days next year so any advice on what to do an where to go would be great :-)
 
Hi,

Guess I'll start looking out for a guy who has very little hair.:D

Anyway, there many places go, I suggest you start by looking for brochures or counters when you arrived at the airport.

Any other places, try to PM me here.

This is an interesting area. I had similar problem some time ago and fixed it by using double rather than integer. Many people don't initially realise that integer only allows a whole number and will fail when it tries to evaluate a fraction or decimal.

Technically an integer takes less memory but unless memory is a real issues I now use double or long where there is any doubt.

Thanks Uncle Joe for picking this one up. It certainly brought back memories of me pulling my hair out (what little I have left) over similar problems. By the way I am in Singapore for a couple of days next year so any advice on what to do an where to go would be great :-)
 

Users who are viewing this thread

Back
Top Bottom