lokanathas
Registered User.
- Local time
- Today, 16:02
- Joined
- Aug 11, 2017
- Messages
- 23
Kindly help with a VBA in access to replace "/" with "" in entire table, table name Master
Create a query in the designer using the replace code shown above. Make sure it works.
Save the query as qryUpdReplaceBackSlash
In the VBA window where you want to run this put the following code.
Currentdb.Execute "qryUpdReplaceBackSlash", dbSeeChanges
Run the code.
Make a new form, put a button on it.
On the Click event press the Event Builder and the VBA code window will open. Paste the line of code. Save the code and open the form.
Now pressing the button will run your query.
If it doesn't work tell us what error code you get.
With CurrentDb
Dim f As DAO.Field, t As DAO.TableDef
Set t = .TableDefs("master")
For Each f In t.Fields
Select Case f.Type
Case 10, 12
.Execute "update master set [" & f.Name & "]=replace([" & f.Name & "],'/','')"
End Select
Next
End With
That means your query is running as a select query, not an update query.am getting Run-time error '3065'
Code:With CurrentDb Dim f As DAO.Field, t As DAO.TableDef Set t = .TableDefs("master") For Each f In t.Fields Select Case f.Type Case 10, 12 .Execute "update master set [" & f.Name & "]=replace([" & f.Name & "],'/','')" End Select Next End With
Public Function replaceX(s1 As String,s2 as string,s3 as string) As String
replaceX = Replace(s1, s2, s3)
End Function