Validation Rule (1 Viewer)

kdt

Registered User.
Local time
Today, 05:21
Joined
Apr 5, 2006
Messages
48
Hi all,

I have a form that records a unique number which requires a full stop to be present. Is there anyway of ensuring a user has to enter a "." somewhere in this box?

Cheers:p
 

KeithG

AWF VIP
Local time
Yesterday, 21:21
Joined
Mar 23, 2006
Messages
2,592
You could use the AfterUpdate event on the textbox to check the string for a period.
 

RV

Registered User.
Local time
Today, 05:21
Joined
Feb 8, 2002
Messages
1,115
Define a Before Update event on your form field using the InStr function to check whether a full stop was entered:

If Instr(Me.fieldname) = 0 Then
MsgBox "You need to enter at least one full stop"
Cancel = True

RV
 

kdt

Registered User.
Local time
Today, 05:21
Joined
Apr 5, 2006
Messages
48
thanks for you replies.
RV, I tried your suggestion but I'm getting an "Expected: list separator" on this line:

If Instr(Me.Study_Number)=0 Then

At least I feel that you've pointed me in the right direction.

Thanks :)
 

kdt

Registered User.
Local time
Today, 05:21
Joined
Apr 5, 2006
Messages
48
right, this is what i have so far. I have added an after update event with the following:

Private Sub Study_Number_AfterUpdate()
If InStr(1, Me.Study_Number, ".", 0) Then

MsgBox "you need to enter at least one full stop"
End If
End Sub

Which is all well, but it does the exact opposite of what I want. I have tried to add

If InStr(1, Me.Study_Number, ".", 0) is False Then

but it doesnt seem to like that. Also I'm trying to make it so that it doesn't allow you to proceed until a Study Number with a full stop has been added. Can someone please put me out of misery. :(

Thanks
 

KeithG

AWF VIP
Local time
Yesterday, 21:21
Joined
Mar 23, 2006
Messages
2,592
PHP:
If InStr(1, Me.Study_Number, ".", 0) is False Then

Try below
PHP:
If InStr(1, Me.Study_Number, ".", 0) =0Then
 

kdt

Registered User.
Local time
Today, 05:21
Joined
Apr 5, 2006
Messages
48
Thanks a lot, that seemed to do the trick! is there a way to stop the user progressing to another field until a full stop has been added?

Thanks
 

RV

Registered User.
Local time
Today, 05:21
Joined
Feb 8, 2002
Messages
1,115
is there a way to stop the user progressing to another field until a full stop has been added

Yes there is.
Put your code in the Before Update event of your control.
Add this line of code after your current code:

Cancel = True

RV
 

kdt

Registered User.
Local time
Today, 05:21
Joined
Apr 5, 2006
Messages
48
thanks a lot mate, your a star!:D
 

Users who are viewing this thread

Top Bottom