Masking based on other data in the form

G

Guest

Hi there,

I've got a database where we are storing patent information. I want to mask
the input of the patent number field based on the patent region. I've created
the form to input the patent information, but I can't figure out how to alter
the mask based on the region.

Example:
world patent numbers have the following structure AA-99-999999-AA
us patents 9,999,999
european patents AA-9-999-999-A9

I've already made the user select the region, how do I alter the mask based
on his selection?
 
J

John Nurick

Hi Wavemancali,

In principle you just do something like this in the AfterUpdate event of
the control where the user selects the region:

Select Case Me.ActiveControl.Value
Case "World"
Me.Controls("txtPatentNumber").InputMask = "blah blah"
Case "US"
...
End Case

In practice, I find input masks are almost always more trouble than
they're worth, and I'd be inclined instead to validate the number after
entry (e.g. using the rgxValidate() function at
http://www.mvps.org/access ).

from your description
world patent numbers have the following structure AA-99-999999-AA
us patents 9,999,999
european patents AA-9-999-999-A9

these regular expressions would do the job:

World "^[A-Z]{2}-\d{2}-\d{6}-[A-Z]{2}$"
US "^\d,\d{3},\d{3}$"
EU "^[A-Z]{2}-\d-\d{3}-\d{3}-[A-Z]\d$"
 

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