Using an IIf statement

  • Thread starter Janice via AccessMonster.com
  • Start date
J

Janice via AccessMonster.com

I am trying to create an IIf statement to return an message.
The user will type a date in a date field which must correspond with a date
that is calculated using a unbound text box.

If the user types in a wrong date then a message should come up saying "Pls
check date" to alert the user that the date typed is incorrect.

Any help would be appreciated..
 
K

KARL

If you enter an invalid date in the criteria of a query
Access will display a message the the entry is an invalid
date.
 
J

Janice via AccessMonster.com

are you saying that I should create the IIF statement in a query
environment?

Because I am creating the statement in an unbound text box on the form..
 
T

tina

assuming that
1) the user will be entering the date in a control (on a form) that's bound
to a date field in the form's RecordSource, and
2) the the unbound text box is on the same form, and
3) the unbound text box is already displaying a date at the time of the data
entry into the form control, then

you can use an If statement in the date control's BeforeUpdate event
procedure (to prevent an incorrect date from being accepted) or in the date
control's AfterUpdate event procedure (to accept the incorrect date, but
still warn the user), as

If Not (Me!MyDateControl = Me!MyUnboundTextbox) Then
Cancel = True 'use this line in the BeforeUpdate event only
Msgbox "Pls check date"
End If

hth
 

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