IIf statement

M

Manton

Access 2000
I have a table with four fields:

-Name - (combo box with a choice of names to pick from)
-Status - (combo box)
-Date Req - default setting is Date () -current date
-Date Comp - this is NOT set to current date for certain reasons.

Data is imported into the database.
The user would simply open a form and with all the imported data present
there for the current date, would only have to select their name from the
Name combo box. The other fields do not have tab stops. So when the user
press's the ENTER key, the next record comes up instead of tabing through
the other fields.
Problem: I would like the Date Comp field (even though by default it is Not
set to current date, would like that field (for just this form) - to be
populated automatically with the current date, when the user selects their
name from the Name combo box. Respectively, if no name is chosen, the Date
Comp field box remains blank.
In the design mode of that form, I have tried to go to the Date Comp (text
box) property box and under the Default Value row typed:
=IIf(IsNull([Name]),IsNull([Date Comp]),[Date Comp]=Date())

This had no effect on populating a current date automatically in the Date
Comp field when a name was chosen.
Note: this particular form is set at not allowing additions of new records
to the existing data.
Any help would be appreciated.
 
M

MacDermott

The DefaultValue property of a textbox is used to assign a value when the
record is created; once the record exists, this property has no use.

It sounds as if you want to make this assignment when a username is
selected; I'd suggest finding an appropriate event procedure (e.g.
cboName_AfterUpdate) to run it in.

HTH
- Turtle
 

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