iif statement

lydz

Registered User.
Local time
Today, 20:00
Joined
Mar 6, 2006
Messages
28
i have a table and im working on two fields
one is the session part of day where you can only enter "Morning", "Afternoon" or "Evening"
Then i have a cost field
Morning and Afternoon both cost £12
Evening costs £15
when someone types in the part of day i want the price to come up automatically
can anyone help me with how to do this?
i tried this in the validation rule box as a way of a test, but it didnt work
: IIf([Session time of day]="Morning",12,0)

help would be great :) thanks
 
I would suggest a simple table that has these values in it. This way your 'time of day' and the associated rates wouldn't be hard coded and you can change them if need be. Say tblRates. In tblRates there would be two flds, 'TimeOfDay' and 'Rate'. Then in the input form for the main table, use a combo box to populate the TimeOfDay fld in the main table. Then in the combo boxes after update event, do code that does a dlookup on tblRates to populate the rate fld in the main table.

Hope this makes sense...
 
I would suggest a simple table that has these values in it. This way your 'time of day' and the associated rates wouldn't be hard coded and you can change them if need be. Say tblRates. In tblRates there would be two flds, 'TimeOfDay' and 'Rate'. Then in the input form for the main table, use a combo box to populate the TimeOfDay fld in the main table. Then in the combo boxes after update event, do code that does a dlookup on tblRates to populate the rate fld in the main table.

Hope this makes sense...
 
thanks man you've helped a lot, just having one problem :eek:

see attached screen dump :) problem is that i dont want the text to be saved i only want the price to be saved, but just the opposite is happening at the moment lol
i used the wizard :) so dont have any code
anyone know of the magical way to fix this problem?:D
 

Attachments

  • form.gif
    form.gif
    42.3 KB · Views: 138
Go into the properties of your combo box.

Look under "Data" tab.

Find "Bound Column"

Change to I"M ASSUMING 2.

That number needs to be whichever column that "price" is in.

IE: Look at your record source field for that combo box, click on the ... box next to it, and see how many columns over your Price field is over (Counting only the columsn that have "is visible" selected). Thats the number you need to put into "Bound Column." IE: Its 2 VISIBLE columns over, put 2 in. Its 3 columns over, but ONLY 2 have VISIBLE checked, then put 2 in.

Also, you could bind the field to column two (it looks like 2 visible columsn, your mornign, afternoon and evening column, and yoru price column) and on the format page, under Column count, it should be "2".

Leave that.

Under column widths, it might be blank, or it might have something like 1";1"

Change that to 1;0

Then it will ONLY show the Morning / Afternoon / Evening listed, but when you click on it, it will put the price in instead.

Hope that helps
 

Users who are viewing this thread

Back
Top Bottom