D
dean.brunne
The code below returns a syntax error in my Alter Table Statement. My
goal is to loop through and delete the same column from all the tables
that do not end in "_F" in a different database.
Appreciate your help. Dean
Function DeleteFields()
Dim rs As DAO.Recordset
Dim rsIn As DAO.Recordset
Dim fld As DAO.Field
Dim varIndex As Variant
Dim DB1 As Database
Dim strSQL As String
Dim strTable As String
Set DB1 = DBEngine.OpenDatabase("C:\Documents and Settings\dbrunne\My
Documents\26 Hawkeye\Regional Trade Baselines
\Fpro_Link_Regional_Non_Promoted.mdb")
strSQL = ("SELECT MSysObjects.Name FROM MSysObjects WHERE " & _
"(MSysObjects.Type=1) AND" & _
"(Left$([Name],1)<>'~')AND" & _
"(Left$([Name],4)<>'Msys')AND" & _
"(Right$([Name],2)<>'_F')" & _
" ORDER BY MSysObjects.Name")
Set rs = DB1.OpenRecordset(strSQL)
Do Until rs.EOF
strTable = rs!Name
DoCmd.RunSQL "ALTER TABLE & 'strTable' & DROP COLUMN [Planning
Customer Name];"
rs.MoveNext
Loop
End Function
goal is to loop through and delete the same column from all the tables
that do not end in "_F" in a different database.
Appreciate your help. Dean
Function DeleteFields()
Dim rs As DAO.Recordset
Dim rsIn As DAO.Recordset
Dim fld As DAO.Field
Dim varIndex As Variant
Dim DB1 As Database
Dim strSQL As String
Dim strTable As String
Set DB1 = DBEngine.OpenDatabase("C:\Documents and Settings\dbrunne\My
Documents\26 Hawkeye\Regional Trade Baselines
\Fpro_Link_Regional_Non_Promoted.mdb")
strSQL = ("SELECT MSysObjects.Name FROM MSysObjects WHERE " & _
"(MSysObjects.Type=1) AND" & _
"(Left$([Name],1)<>'~')AND" & _
"(Left$([Name],4)<>'Msys')AND" & _
"(Right$([Name],2)<>'_F')" & _
" ORDER BY MSysObjects.Name")
Set rs = DB1.OpenRecordset(strSQL)
Do Until rs.EOF
strTable = rs!Name
DoCmd.RunSQL "ALTER TABLE & 'strTable' & DROP COLUMN [Planning
Customer Name];"
rs.MoveNext
Loop
End Function