replace "www." with "http://www." to textbox

MartynE

Registered User.
Local time
Today, 12:21
Joined
Mar 27, 2013
Messages
49
Hi,
NOTE: I couldn't post this question cause this is my 2nd post and I can not post links so that's why I had to add the "-" in between the "ht-tp://" and "ww-w" Please read through this I know it's very stupid but I had to do this or either spam somewhere on the site :banghead:

For some of you this is gonna be a real easy question but I'm new to access and VBA and get figure this one out.

The problem is that for our website textbox button to work the address has to start with "ht-tp://" while my co-workers address websites with just "ww-w." So I had to find out how we can replace or add the ht-tp in front. It doesn't really matter how this is done as long as it works.

The things I've tried are:

This is when is clicked on a button next to the textbox:

Code:
   Dim strPhrase As String
   Dim strOldWord As String
   Dim strNewWord As String
    
   strPhrase = "Me.[website]"
   strOldWord = "ww-w."
   strNewWord = "ht-tp://ww-w."
    
   strPhrase = Replace(strPhrase, strOldWord, strNewWord, 1, -1)
And this one on the same button:

Code:
If Left([website], 3) = "ww-w" Then

Replace("Me.[website]", "ww-w.", "ht-tp://")
Else
End If
Last try was this after update event on the textbox itself:

Code:
Private Sub website_AfterUpdate()

If Left([website], 3) = "w-ww" Then

Left([website], 10) = "ht-tp://ww-w"

Else
End If
Thanks for giving this any thought at all :D

Sincerely,

MartynE

Note: I work in Access 2003 on a Windows 7 machine.
 
Last edited:
Forward slashes are used on the web.
http://
 
That is very true I will edit the first post! I feel stupid.. :banghead:

But still I don't know how to replace or add the http to the textbox ( or record)
 
You should test for http: as not all websites use www.
Something like:
Code:
If left(me.website, 4) <> "HTTP" then
me.website = "http://" & me.website
'else
'do nothing (tested also for HTTPS)
End if
I would place the code in the afterupdate event of te textbox or in the before update event of the form.
 

Users who are viewing this thread

Back
Top Bottom