How Can I This Function Please

S

SEAN DI''''ANNO

Hi,

I found this article about validating Postcodes and would really like to use
it.

http://www.mvps.org/access/modules/mdl0063.htm


I have copied the code to a new module and on my Data Input Form and have
used this code for the field Postcode;

Private Sub Postcode_BeforeUpdate(Cancel As Integer)
If Not rgxValidate([Postcode], rgxZIP_UK) Then
MsgBox "I don't like " & Me.Postcode
Cancel = True
End If
End Sub

However when I compile, it tells me that rgxvalidate is a ambiguous name
even though, I have only copied it once. Am I not calling the function
properly? Can anyone please tell me how I can use this function on my form
please.
 
G

gllincoln

Hi Sean,

I took a look at the article - looks like a useful function. You may know
this, but just in case you missed the reference in the article to 'uses
VBScript regular expression object (v 5.5)'?
By default, the regex library is not referenced. If you want to use Regex
code - then you need to add a reference to the appropriate library.

In case you (or someone else reading this) isn't sure about how to do this.

Open your database. Press Alt-F11 to bring up the Visual Basic window.

On the menu, select Tools, References, you will see a rather large list of
items. The one you need for this function is titled 'Microsoft VBScript
Regular Expressions 5.5'

Click on the checkbox beside this line, then click okay.

If you have already done this - make really really sure you don't have two
copies of that function pasted into your module. In the Visual Basic window
while focus in on the code frame (where you see your programming code), hit
Ctrl-F insert rgxValidate and select the Current Project as the area to
search. You will find the instances where you have called the function but
there should only be one line that starts with Function rgxValidate,

Hope this helps...
Gordon\
 
S

SEAN DI''''ANNO

Hi Gordon,

Thats great thanks, and although I know how to add references, I did not
read it carefully and so Im glad you mentioned which one I needed to add
because I had forgotten lol. Also, despite copying it only once, what I
failed to realise was that another piece of useful code which I used also had
a function of the same name which I did not relise becuase it was in a
differrent module. Do I need to look at each module or is there a way of
finding function names globally through all code?



gllincoln said:
Hi Sean,

I took a look at the article - looks like a useful function. You may know
this, but just in case you missed the reference in the article to 'uses
VBScript regular expression object (v 5.5)'?
By default, the regex library is not referenced. If you want to use Regex
code - then you need to add a reference to the appropriate library.

In case you (or someone else reading this) isn't sure about how to do this.

Open your database. Press Alt-F11 to bring up the Visual Basic window.

On the menu, select Tools, References, you will see a rather large list of
items. The one you need for this function is titled 'Microsoft VBScript
Regular Expressions 5.5'

Click on the checkbox beside this line, then click okay.

If you have already done this - make really really sure you don't have two
copies of that function pasted into your module. In the Visual Basic window
while focus in on the code frame (where you see your programming code), hit
Ctrl-F insert rgxValidate and select the Current Project as the area to
search. You will find the instances where you have called the function but
there should only be one line that starts with Function rgxValidate,

Hope this helps...
Gordon\
SEAN DI''''ANNO said:
Hi,

I found this article about validating Postcodes and would really like to
use
it.

http://www.mvps.org/access/modules/mdl0063.htm


I have copied the code to a new module and on my Data Input Form and have
used this code for the field Postcode;

Private Sub Postcode_BeforeUpdate(Cancel As Integer)
If Not rgxValidate([Postcode], rgxZIP_UK) Then
MsgBox "I don't like " & Me.Postcode
Cancel = True
End If
End Sub

However when I compile, it tells me that rgxvalidate is a ambiguous name
even though, I have only copied it once. Am I not calling the function
properly? Can anyone please tell me how I can use this function on my
form
please.
 

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