Validation rule of 6 digits in an Access Database Attribute

RobertSmith101

New Member
Joined
Feb 12, 2003
Messages
16
I would like to know how I could ensure that onnly 6 digits were input into my CustomerID attribute. (I have Access 2002 and its not as simple as Access 2000) I need a error box to come up when (6 isn't entered) in datasheet view and the data form view.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
I haven't used Access 2002, but it seems like the code should be the same:

Code:
YourControl_BeforeUpdate(Cancel as Integer)
if len(me.YourControl)<>6 then
msgbox "Tell User that he screwed up"
me.YourControl.undo
Cancel=true
end if
End Sub
 
Upvote 0
Yes, in Design view, right-click on the Control in question and then, under Properties->Events->On Before Update->Code Builder and then this will pop up:

YourControl_BeforeUpdate(Cancel as Integer)

End Sub

You'll have to fill between the lines with the appopriate logic (Replace YourControl in my generic code with the name of the control in question).
 
Upvote 0

Forum statistics

Threads
1,221,522
Messages
6,160,308
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top