Update with replace (1 Viewer)

mester

Member
Local time
Today, 08:00
Joined
Apr 2, 2020
Messages
63
Hi everyone,
I have a table "x" where there is a colon named "path", all the lignes in that colon start by G:\&.........
I have a form, in the form i have two txtbox, the first one named "P1" and the second is "P2" .
When i open the form, the P1 brings the start of the colon "path" from the table "x" where there is "&" , so i get only "G:\&"
The P2 brings the start of my actuel and reel path of my data where there is "&" , let's say "F:\&"
So what i want is to use a vba code to change all the linges in the colon path in the table X form "G:\&" to "F:\&" using the txtbox P1 and P2 in the form.
I used this code but it doesn't work for me:
Docmd.runsql "UPDATE X SET path=Repace(Path, me.P2, me.P1)"

I hope there is a way to do that, thanks
 

June7

AWF VIP
Local time
Yesterday, 23:00
Joined
Mar 9, 2014
Messages
5,488
Have to concatenate the textboxes and use apostrophe delimiters:

CurrentDb.Execute "UPDATE X SET path=Replace(Path,'" & Me.P2 & "','" & Me.P1 & "')"
 

mester

Member
Local time
Today, 08:00
Joined
Apr 2, 2020
Messages
63
Have to concatenate the textboxes and use apostrophe delimiters:

CurrentDb.Execute "UPDATE X SET path=Replace(Path,'" & Me.P2 & "','" & Me.P1 & "')"
Thanks a lot, i'll try it and tell you the result, God bless you
 

mester

Member
Local time
Today, 08:00
Joined
Apr 2, 2020
Messages
63
Have to concatenate the textboxes and use apostrophe delimiters:

CurrentDb.Execute "UPDATE X SET path=Replace(Path,'" & Me.P2 & "','" & Me.P1 & "')"
Thanks a lot, it works for me.
 

Users who are viewing this thread

Top Bottom