Help using If statement

M

MitziUK

Can someone please help me with and If statement.

In my database I have a field which lists (via Combo Box) the following
service types:

Small
Medium
Large
9,000
10,000-Interim
20,000-Main

When I add another record to the service table I want the database to look
at the previous records 'service type' and say:

If Small entered, then next record can only be Medium
If Medium entered, then next record can only be Large
If Large entered, then next record can only be Small
If 10,000-Interim entered, then next record can only be 20,000-Main
If 20,000-Main entered, then next record can only be 10,000-Interim
but if 9,000 entered, then next record CAN be 9,000

(this is because Renaults are serviced every 9,000) the others are a little
more complicated.

A quick response most gratefully appreciated and also for futre reference a
reference web site where I can understand more about If statements.

Thanks
 
M

Madhivanan

You need to have datetime field at your table.
Before inserting the record, select the service type of the last record
which has maximum datetime. Check that and according to that insert
record. Otherwise have an identity column and write query

Select servicetype from table where id in (select max(id) from table)

Madhivanan
 
M

MitziUK

Just clicked what you mean (having a blonde day)

OK the table has a datetime field - Service Date. Guess I need to create
the sub form that this Servcice data will go in and create a query for the
report.

I may well post again as I struggle with SQL code.
 
Top