Help with validation

D

Daniel Haley

I was wondering if someone could please help me with validation rules
for a table. I am running Access 2003.

I have a table called tblSite, which has the following fields:
1. SiteID (Autonumber)
2. SiteName (Text)
3. URL (Hyperlink)
4. DateCreated (Date)
5. DateModified (Date)

I am trying to validate the URL field. It is not a required field.
Here is my (non-functioning) existing rule:

Is Null Or Like ("http://*") Or Like ("https://*") Or Like ("ftp://*")
Or Like ("file://")

It does not work. Here is how it responds in the following situations:

Example Result
------------------------------
Null Value Works
http://test.com Validation message returned
test Validation message returned

If I change the like statements so they are Like("*http://*") -- note
the new wildcard -- it will accept the string I want, but it would also
accept nonsense like "BHDFihttp://"

I'm baffled. Perhaps the colon and slash cannot be used? Can anyone
provide insight?

Thanks,

Dan
 
D

Daniel Haley

I have found a workaround, although not a solution. If anyone has a
real solution please post it.

It seems that the hyperlink datatype contains more than what is
displayed on scheme. Without knowing how these strings are coded, I
cannot parse them.

Here's the work around.

1. Change the datatype of the URL field to text

2. Keep the same validation rule.

3. If you want to activate the URL, just create an event on a form. For
instance, if you want to go to the page when someone presses a command
button, insert this into the button's onclick event:

Application.FollowHyperlink Address:=Me.URL.value, newwindow:=True

I hope it helps someone else too.
 

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