Reputation: 21
I am new to MS ACCESS & SQL
I am trying to replace all the "[" & "]" within the table. Am I suppose to use REPLACE command or should Select & Loop through the Table?
Either way, I don't know how to write it in VBA. Thanks for help
I tried this, and it is not working
DoCmd.RunSQL "SELECT REPLACE" & "(StudentFirstName,'[','')" & "FROM StudentName"
See the Table Structure:
Upvotes: 0
Views: 104
Reputation: 294
Just run an UPDATE
query with REPLACE()
function:
UPDATE tableName SET fieldName = REPLACE(fieldName, '[', '')
and than with the other bracket:
UPDATE tableName SET fieldName = REPLACE(fieldName, ']', '')
If you want to use in your vba code:
Docmd.RunSQL "UPDATE tableName SET fieldName = REPLACE(fieldName, '[', '')"
Docmd.RunSQL "UPDATE tableName SET fieldName = REPLACE(fieldName, ']', '')"
Remember: SELECT
it's used only for VIEW data and not for edit.
If you want to EDIT data in your table you need to use UPDATE
.
Upvotes: 1