Dustin Stanley
asked on
MS Access Replace Spaces In Title With Characters Like (-) Dashes In a New Field
I am wanting to keep track of my Products Website page URL. My website uses the products title as the URL extension.
Example:
Website name = www.Store.com
Product Name = Yellow Big Toy School Bus
Website URL Complete = www.Store.com/Product/ Yellow-Big-Toy-Scholl-Bus/
So how can I do this the easy way and concatenate "www.Store.com/Product/" & "Title with Dashes" & "/"
I know how to concatenate but I have to replace them spaces?
Thanks!
Example:
Website name = www.Store.com
Product Name = Yellow Big Toy School Bus
Website URL Complete = www.Store.com/Product/ Yellow-Big-Toy-Scholl-Bus/
So how can I do this the easy way and concatenate "www.Store.com/Product/" & "Title with Dashes" & "/"
I know how to concatenate but I have to replace them spaces?
Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
To be fair ... I was kidding - but you will need brackets ([]) around the FieldName ...
ASKER
Yes Joe that was a perfect LOL ;)
Took me a minute but its those little errors that can mess Access all up!
Ok I am at a loss. With the parenthesis I get a Compile Error expected: =
Without the Parenthesis I get nothing to replace the spaces. I have tried with brackets without brackets. Calling a public sub.
I am trying to do this on an AfterUpdate on a Control called SkuNm and then get the other Control SkuIDURL to update correctly. It shows and updates the URL but still has spaces! These below is what I have tried. Plus more.
Private Sub SkuNm_AfterUpdate()
Me.SkuIDURL.value = "htt p:// Store .com/index.php/product/" & (Me.SkuNm.value) & "/"
'Replace Me![SkuIDURL].value," ","-"
'Replace Forms!frmSkusEntry!SkuIDUR L.value, " ", "-"
'Replace [Forms]![frmSkusEntry]![Sk uIDURL].va lue, " ", "-"
'Call URLSpaceCorrection
End Sub
**I broke the link up above on purpose.
Thanks for the help!
Took me a minute but its those little errors that can mess Access all up!
Ok I am at a loss. With the parenthesis I get a Compile Error expected: =
Without the Parenthesis I get nothing to replace the spaces. I have tried with brackets without brackets. Calling a public sub.
I am trying to do this on an AfterUpdate on a Control called SkuNm and then get the other Control SkuIDURL to update correctly. It shows and updates the URL but still has spaces! These below is what I have tried. Plus more.
Private Sub SkuNm_AfterUpdate()
Me.SkuIDURL.value = "htt p:// Store .com/index.php/product/" & (Me.SkuNm.value) & "/"
'Replace Me![SkuIDURL].value," ","-"
'Replace Forms!frmSkusEntry!SkuIDUR
'Replace [Forms]![frmSkusEntry]![Sk
'Call URLSpaceCorrection
End Sub
**I broke the link up above on purpose.
Thanks for the help!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Nevermind I got it! Does this look good or is there a better way? Thanks for the help!
Me.SkuIDURL.value = "htt p://Store .com/index.php/product/" & (Me.SkuNm.value) & "/"
Me.SkuIDURL.value = Replace(Me.[SkuIDURL].value, " ", "-")
better to do it all in one step. Also test SkuNm first to make sure it is filled out -- try the code I gave you -- you still have spaces -- there should not be any.
You are referencing 2 names: SkuIDSurpURL and SkuIDURL. This field should be called SkuURL in the table design -- so
1. close the form
2. fix that and change the Control Source and Name for that control to match the field name
You are referencing 2 names: SkuIDSurpURL and SkuIDURL. This field should be called SkuURL in the table design -- so
1. close the form
2. fix that and change the Control Source and Name for that control to match the field name
ASKER
Ok Crystal thanks. The spaces were on purpose so there isn't a true link generated here in the forum to some random site.
you're welcome
I also added to my comment, maybe after you read it ~
I also added to my comment, maybe after you read it ~
ASKER
Nope error just SkuIDURL
I would remove ID from the fieldname to be consistent. When ID is in a fieldname, that implies it is a Long Integer (or AutoNumber). At least that is what we did when designing your tables. This field is Text.
> "SkuIDSurpURL and SkuIDURL"
I see I am not the only ones who edits posts! You fixed that ...
> "SkuIDSurpURL and SkuIDURL"
I see I am not the only ones who edits posts! You fixed that ...
ASKER
I don't know why the single step one wasn't working. It just kept adding on to the existing sting value. But this one is working perfect for me.
I have the ID in there because it is the URL to that specific SkuID. Which I can change it.
Private Sub SkuNm_AfterUpdate()
If Not IsNull(Me.SkuNm.value) Then
Me.SkuNm.value = Trim(Me.SkuNm.value)
Me.SkuIDURL.value = "http://Store.com/index.php/product/" & (Me.SkuNm.value) & "/"
Me.SkuIDURL.value = Replace(Me.[SkuIDURL].value, " ", "-")
Else
Exit Sub
End If
End Sub
I have the ID in there because it is the URL to that specific SkuID. Which I can change it.
ASKER
Thanks For The Help!
you're welcome, Dustin ~ happy to help
@Crystal ... I thought it was a field name in a query, in which case you would need brackets around it, spaces or not.
But since it's a value on a Form, then no.
But since it's a value on a Form, then no.
ASKER