Is there a way to rename the fields in queries using vba. I am using the code below but get the error "Can't assign to read only property." at the point that I have highlighted.
The reason that I need to do this is because I am renaming all the fields in the tables to eliminate white spaces. I then need to run code to try and catch all these changes in as many queries, forms, reports and calculations as possible. The query part is beating me up right now.....
Function ChangeQueryFieldNames()
Dim db As DAO.Database, tdf As DAO.TableDef, fld As DAO.Field
Set db = CurrentDb
For Each qry In db.QueryDefs
For Each fld In qry.Fields
fld.SourceField = trim(fld.Sourcefield) '<<<<<<<<<<<
Next
Next
End Function
The reason that I need to do this is because I am renaming all the fields in the tables to eliminate white spaces. I then need to run code to try and catch all these changes in as many queries, forms, reports and calculations as possible. The query part is beating me up right now.....
Function ChangeQueryFieldNames()
Dim db As DAO.Database, tdf As DAO.TableDef, fld As DAO.Field
Set db = CurrentDb
For Each qry In db.QueryDefs
For Each fld In qry.Fields
fld.SourceField = trim(fld.Sourcefield) '<<<<<<<<<<<
Next
Next
End Function