Well I post my code so it can be looked at but my problem seems to stem from this statement:
dbs.Execute ("CREATE TABLE PARTDATACorrections(MTX TEXT, IGNORE TEXT, ....);")
VBA or Access 97 or whatever the reason won't let me use IGNORE as a Field Name. Is this a reserved word? If so, then why or how do I work my way around it, because I need it to create a table with the one of the fields labeled IGNORE.
Sub testComparePARTDATA()
Call ComparePARTDATA("PARTDATAMaster", "PARTDATA")
End Sub
Sub ComparePARTDATA(PARTDATAMaster As String, PARTDATA As String)
Dim dbs As Database
Dim recPARTDATAMaster As Recordset
Dim recPARTDATA As Recordset
Dim tdf As TableDef
Dim fld As Field
Dim FieldChanged As Boolean
Dim Check2, Check3, Check4, Check5, Check6, Check7 As Boolean
Dim MTX, AHORSRV, DHTHRESH, MDRSSTHS, DMINRSSI, CONNECT, IGNORE As String
Dim m As Integer
Set dbs = CurrentDb
Set recPARTDATAMaster = dbs.OpenRecordset(PARTDATAMaster)
Set recPARTDATA = dbs.OpenRecordset(PARTDATA)
Set tdf = dbs.TableDefs(PARTDATAMaster)
dbs.TableDefs.Delete "PARTDATACorrections"
dbs.Execute ("CREATE TABLE PARTDATACorrections(MTX TEXT, IGNORE TEXT, RSSACMIN TEXT, SS_SUFF TEXT);")
recPARTDATAMaster.MoveFirst
recPARTDATA.MoveFirst
Do Until recPARTDATAMaster.EOF
m = 0
10 For Each fld In tdf.Fields
If m = 0 Then MTX = recPARTDATAMaster(fld.Name)
If recPARTDATAMaster(fld.Name) <> recPARTDATA(fld.Name) Then
If m = 0 Then
recPARTDATA.MoveNext
If recPARTDATA.EOF Then
MsgBox "Missing MTX" & MTX
GoTo 20
End If
GoTo 10
ElseIf m = 2 Then
Check2 = True
AHORSRV = recPARTDATAMaster(fld.Name)
ElseIf m = 3 Then
Check3 = True
DHTHRESH = recPARTDATAMaster(fld.Name)
ElseIf m = 4 Then
Check4 = True
MDRSSTHS = recPARTDATAMaster(fld.Name)
ElseIf m = 5 Then
Check5 = True
DMINRSSI = recPARTDATAMaster(fld.Name)
ElseIf m = 6 Then
Check6 = True
CONNECT = recPARTDATAMaster(fld.Name)
ElseIf m = 7 Then
Check7 = True
IGNORE = recPARTDATAMaster(fld.Name)
End If
FieldChanged = True
End If
m = m + 1
Next fld
If FieldChanged = True Then
dbs.Execute ("INSERT INTO PARTDATACorrections(MTX, AHORSRV, DHTHRESH, MDRSSTHS, DMINRSSI, CONNECT, IGNORE) " & "VALUES('" & MTX & "', '" & AHORSRV & "', '" & DHTHRESH & "', '" & MDRSSTHS & "', '" & DMINRSSI & "', '" & CONNECT & "', '" & IGNORE & "');")
End If
FieldChanged = False
MTX = ""
AHORSRV = ""
DHTHRESH = ""
MDRSSTHS = ""
DMINRSSI = ""
CONNECT = ""
IGNORE = ""
recPARTDATAMaster.MoveNext
recPARTDATA.MoveFirst
Loop
20 Set recPARTDATAMaster = Nothing
Set recPARTDATA = Nothing
dbs.Close
I know this code may seem a little confusing but it all works except for the line where I try to create the table PARTDATACorrections. When I run the code it gives me a Syntax error. I appreciate any help on this. Thanks
dbs.Execute ("CREATE TABLE PARTDATACorrections(MTX TEXT, IGNORE TEXT, ....);")
VBA or Access 97 or whatever the reason won't let me use IGNORE as a Field Name. Is this a reserved word? If so, then why or how do I work my way around it, because I need it to create a table with the one of the fields labeled IGNORE.
Sub testComparePARTDATA()
Call ComparePARTDATA("PARTDATAMaster", "PARTDATA")
End Sub
Sub ComparePARTDATA(PARTDATAMaster As String, PARTDATA As String)
Dim dbs As Database
Dim recPARTDATAMaster As Recordset
Dim recPARTDATA As Recordset
Dim tdf As TableDef
Dim fld As Field
Dim FieldChanged As Boolean
Dim Check2, Check3, Check4, Check5, Check6, Check7 As Boolean
Dim MTX, AHORSRV, DHTHRESH, MDRSSTHS, DMINRSSI, CONNECT, IGNORE As String
Dim m As Integer
Set dbs = CurrentDb
Set recPARTDATAMaster = dbs.OpenRecordset(PARTDATAMaster)
Set recPARTDATA = dbs.OpenRecordset(PARTDATA)
Set tdf = dbs.TableDefs(PARTDATAMaster)
dbs.TableDefs.Delete "PARTDATACorrections"
dbs.Execute ("CREATE TABLE PARTDATACorrections(MTX TEXT, IGNORE TEXT, RSSACMIN TEXT, SS_SUFF TEXT);")
recPARTDATAMaster.MoveFirst
recPARTDATA.MoveFirst
Do Until recPARTDATAMaster.EOF
m = 0
10 For Each fld In tdf.Fields
If m = 0 Then MTX = recPARTDATAMaster(fld.Name)
If recPARTDATAMaster(fld.Name) <> recPARTDATA(fld.Name) Then
If m = 0 Then
recPARTDATA.MoveNext
If recPARTDATA.EOF Then
MsgBox "Missing MTX" & MTX
GoTo 20
End If
GoTo 10
ElseIf m = 2 Then
Check2 = True
AHORSRV = recPARTDATAMaster(fld.Name)
ElseIf m = 3 Then
Check3 = True
DHTHRESH = recPARTDATAMaster(fld.Name)
ElseIf m = 4 Then
Check4 = True
MDRSSTHS = recPARTDATAMaster(fld.Name)
ElseIf m = 5 Then
Check5 = True
DMINRSSI = recPARTDATAMaster(fld.Name)
ElseIf m = 6 Then
Check6 = True
CONNECT = recPARTDATAMaster(fld.Name)
ElseIf m = 7 Then
Check7 = True
IGNORE = recPARTDATAMaster(fld.Name)
End If
FieldChanged = True
End If
m = m + 1
Next fld
If FieldChanged = True Then
dbs.Execute ("INSERT INTO PARTDATACorrections(MTX, AHORSRV, DHTHRESH, MDRSSTHS, DMINRSSI, CONNECT, IGNORE) " & "VALUES('" & MTX & "', '" & AHORSRV & "', '" & DHTHRESH & "', '" & MDRSSTHS & "', '" & DMINRSSI & "', '" & CONNECT & "', '" & IGNORE & "');")
End If
FieldChanged = False
MTX = ""
AHORSRV = ""
DHTHRESH = ""
MDRSSTHS = ""
DMINRSSI = ""
CONNECT = ""
IGNORE = ""
recPARTDATAMaster.MoveNext
recPARTDATA.MoveFirst
Loop
20 Set recPARTDATAMaster = Nothing
Set recPARTDATA = Nothing
dbs.Close
I know this code may seem a little confusing but it all works except for the line where I try to create the table PARTDATACorrections. When I run the code it gives me a Syntax error. I appreciate any help on this. Thanks