write over text box with iif statement

B

babs

i have a text box parking amount - I have the control source set to
=iif([parking included]=yes,15,0) It works when the parking included is
check so $15 goes into parking amount and when not checked get the $0
95% of the time it is $15 but occasionaly it may be different. I am not
able to write over the $15 amount but I would like to once in a while write
over with a different amount - what am I missing??

thanks,
Barb
 
J

Jeff Boyce

Barb

Using an IIF() statement to set what a textbox displays DOES NOT change what
is stored in the underlying table.

If you want a message to display on a form, use a separate textbox and set
it's value to that IIF() statement. Keep a textbox bound to the underlying
data if you want to be able to change it.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
C

Clifford Bass

Hi Barb,

As this is a value that may get overridden for some reason, you will
need to store the parking amount in your table. Once you add the column to
your table, you will need to set the Control Source of the parking amount
text box to that column. Then you will need to create an After Update event
on your "parking included" check box. It's contents would look something
like this if your parking amount column is named "Parking_Amount":

If [parking included] Then
[Parking_Amount] = 15
Else
[Parking_Amount] = 0
End If

Now, you can check the box and it will put $15.00 into the parking
amount, but you can then change it to say $10.00.

You may also want to add an After Update event to the Parking_Amount
text box that will set the "parking included" check box if someone just
enters a value into the Parking_Amount box without first checking the parking
included check box:

[parking included] = (Nz([Parking_Amount], 0) <> 0)

Hope that helps,

Clifford Bass
 
B

babs

Awesome - thanks!!!

Clifford Bass said:
Hi Barb,

As this is a value that may get overridden for some reason, you will
need to store the parking amount in your table. Once you add the column to
your table, you will need to set the Control Source of the parking amount
text box to that column. Then you will need to create an After Update event
on your "parking included" check box. It's contents would look something
like this if your parking amount column is named "Parking_Amount":

If [parking included] Then
[Parking_Amount] = 15
Else
[Parking_Amount] = 0
End If

Now, you can check the box and it will put $15.00 into the parking
amount, but you can then change it to say $10.00.

You may also want to add an After Update event to the Parking_Amount
text box that will set the "parking included" check box if someone just
enters a value into the Parking_Amount box without first checking the parking
included check box:

[parking included] = (Nz([Parking_Amount], 0) <> 0)

Hope that helps,

Clifford Bass

babs said:
i have a text box parking amount - I have the control source set to
=iif([parking included]=yes,15,0) It works when the parking included is
check so $15 goes into parking amount and when not checked get the $0
95% of the time it is $15 but occasionaly it may be different. I am not
able to write over the $15 amount but I would like to once in a while write
over with a different amount - what am I missing??

thanks,
Barb
 

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