A really quick question

B

bmacrow

Ok, so I am currently building an archiving section for a database work have
thrown me neck deep into creating (never touched access until i started work
on this!). I have created a fuction that archives based on a date, and there
is a validation rule in the code to check that a date has been entered in the
text box, that validation rule is as follows:

if not IsDate(me.Date1) then
msgbox "You have not entered a date",,"Cannot archive records"
me.Date1.SetFocus
exit sub
end if

What i now need is functionality to archive by ID number, so ideally want to
alter that validation code so it checks for numbers, not dates.

Anyone able to help?

Regards

Ben
 
P

Paolo

Hi bmacrow,
instead of isdate use isnumeric. the following is what access help saìtate
about this function:

Returns a Boolean value indicating whether an expression can be evaluated as
a number.

Syntax
IsNumeric(expression)

The required expression argument is a Variant containing a numeric
expression or string expression.

Remarks
IsNumeric returns True if the entire expression is recognized as a number;
otherwise, it returns False.
IsNumeric returns False if expression is a date expression.

HTH Paolo
 
K

Klatuu

Ideally, Such validation rules should be in the Form Before Update event so
you can cancel the update if a required value has not been entered in a
control.

Private Sub Form_BeforeUpdate(Cancel As Integer)

If IsNull(Me.txtID) Then
MsgBox " And ID is required"
Cancel = True
Me.txtID.SetFocus
End IF
 

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