Form not working? Expression trouble... (1 Viewer)

carrybag93

Registered User.
Local time
Tomorrow, 01:09
Joined
May 24, 2012
Messages
73
I've made an order form for my database based on the table 'Sales'. Four of the fields include:

VIP? (Yes/No)
After Discount (Currency Calculated)
Taxable? (Yes/No)
After GST (Currency Calculated)

If the VIP box is checked, the After Discount field displays the Subtotal (another calculated field displayed before the VIP? field) -5%. This one seems to work fine. In the form, when I tick VIP?, 5% is taken off the Sub Total.

This is the expression I used:

IIf([VIP Discount?],([After Discount]-([After Discount]*0.05)),[After Discount])

I now want the After GST field to do the same, except take the amount in the After Discount field and add on 10% when the Taxable? field is ticked.

I put this expression in the After GST field:

IIf([Taxable?],([After Discount]+([After Discount]*0.1)),[After Discount])

but when I tick the Taxable? field, it changes nothing.

How do I fix this? :banghead:
 

VilaRestal

';drop database master;--
Local time
Today, 16:09
Joined
Jun 8, 2011
Messages
1,046
Firstly, make it easier and have them as:

=IIf([VIP Discount?],0.95,1)*[After Discount]

=IIf([Taxable?],1.1,1)*[After Discount]

I would try: delete the second textbox, copy and paste the first and modify the copy's formula to the 2nd.
 

carrybag93

Registered User.
Local time
Tomorrow, 01:09
Joined
May 24, 2012
Messages
73
How do you change a formula in a form?
 

carrybag93

Registered User.
Local time
Tomorrow, 01:09
Joined
May 24, 2012
Messages
73
When I change the formula in the control source, a little exclamation mark comes up that says Invalid Control Property: Control Source. What does that mean? I just typed in the expression into the control source.
 

carrybag93

Registered User.
Local time
Tomorrow, 01:09
Joined
May 24, 2012
Messages
73
Never mind, the exclamation mark just wants to fight. I will just leave it alone :p
 

VilaRestal

';drop database master;--
Local time
Today, 16:09
Joined
Jun 8, 2011
Messages
1,046
:D

Expressions in a control's controls source need to start with =
 

carrybag93

Registered User.
Local time
Tomorrow, 01:09
Joined
May 24, 2012
Messages
73
Yeah, I started them both with the =, but only the 'After Discount' field brought up the exclamation mark, so I changed it back to how it was before, and that worked again. But changing the 'After GST' field how you told me fixed the original problem, so it all works now. Thanks :)
 

carrybag93

Registered User.
Local time
Tomorrow, 01:09
Joined
May 24, 2012
Messages
73
Ok, I closed my entire database just earlier, and when I opened it back up at looked at my 'Order' form, the 'After GST' field has turned into saying #Name?
What does this mean? Why has this happened?
 

PNGBill

Win10 Office Pro 2016
Local time
Tomorrow, 03:09
Joined
Jul 15, 2008
Messages
2,271
The control source is not working. The expression may have a typo or other error that causes it not to return a value for the control.
 

carrybag93

Registered User.
Local time
Tomorrow, 01:09
Joined
May 24, 2012
Messages
73
I just checked it and retyped the expression, but it didn't work. The field when in 'view' says #Name, but when it's in 'design', it says the expression (which I'm pretty sure is correct!) Can you see anything wrong with it:

=IIf([Taxable?],1.1,1)*[After Discount]
 

carrybag93

Registered User.
Local time
Tomorrow, 01:09
Joined
May 24, 2012
Messages
73
The entire bracket is ([Taxable?],1.1,1)
Then it adds some. Is there supposed to be a bracket around the entire lot?
 

PNGBill

Win10 Office Pro 2016
Local time
Tomorrow, 03:09
Joined
Jul 15, 2008
Messages
2,271
I just responded to what you posted which does not have the closing ")"

Best to use the Hash Symbols when posting code
eg
Code:
=IIf([Taxable?],1.1,1)*[After Discount])
iif() is a function and must have equal brackets - which you have.

Where the error is is dependant on your database.
Why have you used "?" in your field name ??
Not wise to use chrs like that in your names.
? is ascii 63 and a Special Character which should be avoided in names.
 

Users who are viewing this thread

Top Bottom