I have been given the task of synchronizing 2 tables in an Access 2000 database. The first table is called TIssues and the second table is called IssLog. Within TIssues there is a field called issueUID (AutoNumber) and in IssLog there is a field called ILIssueNumber (Text). What I'm trying to do is to see if any records in TIssues exist in IssLog by comparing the 2 fields above (issueUID -> ILIssueumber). I created a function (see code below) to do this but keep getting one of the following error messages:
"Run-time error 3077 Syntax error (missing operator) in expression"
or
"Run-time error 3070 The Microsoft Jet database engine does not recognize 'issueUID' as a valid field name or expression"
or
"Run-time error 3070 The Microsoft Jet database engine does not recognize 'SIR210' as a valid field name or expression"
As you'll see from the code below I have tried different different methods for the criteria but none of them work.
The things to be aware of are that issueUID in table TIssues is an AutoNumber whereas ILIssueNumber in IssLog is Text. And just to complicate things a bit further, the values in ILIssueNumber are appended with "SIR" e.g. SIR100, SIR101 etc, etc.
If anybody can help I would be most grateful.
Function Code:Function CompareIssues()
Dim db As DAO.Database
Dim rsTIssues As DAO.Recordset
Dim rsIssLog As DAO.Recordset
Dim strCriteria As String
Set db = CurrentDb
Set rsTIssues = db.OpenRecordset("TIssues", dbOpenDynaset)
Set rsIssLog = db.OpenRecordset("IssLog", dbOpenDynaset)
With rsTIssues
.MoveFirst
Do While Not .EOF
'strCriteria = "[ILIssueNumber] = SIR" & .Fields("issueUID") ' If field is numberic
'strCriteria = "[IssueNumber] = '" & .Fields("issueUID") & "'" ' If field is string
'strCriteria = "[ILIssueNumber] = SIR" & CStr(.Fields("issueUID"))
'strCriteria = "[ILIssue Number] = SIR'" & CStr(.Fields("issueUID")) & "'" ' If field is string
'strCriteria = "[ILIssueNumber] = SIR" & CStr(.Fields("issueUID")) & ""
strCriteria = "CStr([ILIssueNumber]) = SIR" & " & CStr(.Fields(issueUID)) & """
rsIssLog.FindFirst strCriteria
If rsIssLog.NoMatch Then
' Put all you record copying stuff here
rsIssLog.AddNew
rsIssLog![ILIssue Number] = "SIR" & rsTIssues!issueUID
rsIssLog![ILFull Description] = rsTIssues!Description
rsIssLog![ILDate Raised] = rsTIssues!whenRaised
rsIssLog![ILTitle] = rsTIssues!shortDescription
rsIssLog![ILResolution] = rsTIssues!answer
rsIssLog![ILRaised By] = rsTIssues!whoRaised
rsIssLog![ILExternal Ref] = rsTIssues!priority
rsIssLog.Update
End If
.MoveNext
Loop
End With
End Function
"Run-time error 3077 Syntax error (missing operator) in expression"
or
"Run-time error 3070 The Microsoft Jet database engine does not recognize 'issueUID' as a valid field name or expression"
or
"Run-time error 3070 The Microsoft Jet database engine does not recognize 'SIR210' as a valid field name or expression"
As you'll see from the code below I have tried different different methods for the criteria but none of them work.
The things to be aware of are that issueUID in table TIssues is an AutoNumber whereas ILIssueNumber in IssLog is Text. And just to complicate things a bit further, the values in ILIssueNumber are appended with "SIR" e.g. SIR100, SIR101 etc, etc.
If anybody can help I would be most grateful.
Function Code:Function CompareIssues()
Dim db As DAO.Database
Dim rsTIssues As DAO.Recordset
Dim rsIssLog As DAO.Recordset
Dim strCriteria As String
Set db = CurrentDb
Set rsTIssues = db.OpenRecordset("TIssues", dbOpenDynaset)
Set rsIssLog = db.OpenRecordset("IssLog", dbOpenDynaset)
With rsTIssues
.MoveFirst
Do While Not .EOF
'strCriteria = "[ILIssueNumber] = SIR" & .Fields("issueUID") ' If field is numberic
'strCriteria = "[IssueNumber] = '" & .Fields("issueUID") & "'" ' If field is string
'strCriteria = "[ILIssueNumber] = SIR" & CStr(.Fields("issueUID"))
'strCriteria = "[ILIssue Number] = SIR'" & CStr(.Fields("issueUID")) & "'" ' If field is string
'strCriteria = "[ILIssueNumber] = SIR" & CStr(.Fields("issueUID")) & ""
strCriteria = "CStr([ILIssueNumber]) = SIR" & " & CStr(.Fields(issueUID)) & """
rsIssLog.FindFirst strCriteria
If rsIssLog.NoMatch Then
' Put all you record copying stuff here
rsIssLog.AddNew
rsIssLog![ILIssue Number] = "SIR" & rsTIssues!issueUID
rsIssLog![ILFull Description] = rsTIssues!Description
rsIssLog![ILDate Raised] = rsTIssues!whenRaised
rsIssLog![ILTitle] = rsTIssues!shortDescription
rsIssLog![ILResolution] = rsTIssues!answer
rsIssLog![ILRaised By] = rsTIssues!whoRaised
rsIssLog![ILExternal Ref] = rsTIssues!priority
rsIssLog.Update
End If
.MoveNext
Loop
End With
End Function
Last edited: