Hi Guys,
Please please please can somebody help me?! Seen some pretty good responses to issues on here so thought to give this a try. So I basically have a macro button that updates a few tables in Access from a Spreadsheet in Excel. There are several sheets but just one sheet seems to be temperamental. I need the code to work so that it adds new records and updates old records. The code that I have is:
Sub Update_Epic_Iteration_Assignment(db As DAO.Database)
'
' Update EPIC_ITERATION_ASSIGNMENT table in i-log database from EPIC_ITERATION_ASSIGNMENT sheet
'
Dim ws As Worksheet
Dim rs As DAO.Recordset
'Select source spreadsheet
Set ws = ActiveWorkbook.Sheets("EPIC_ITERATION_ASSIGNMENT")
'loop through entries
i = 3
While (ws.Cells(i, 1).value <> "")
If rs Is Nothing Then
Set rs = db.OpenRecordset("EPIC_ITERATION_ASSIGNMENT", dbOpenDynaset)
End If
rs.FindFirst ("Epic_Title=" & ws.Cells(i, 1).value)
If Not rs.NoMatch Then 'Record exists
With rs
.Edit
![Iteration_Assignment_Content] = ws.Cells(i, 2).value
![Iteration_id] = ws.Cells(i, 3).value
'Update Record into Database
.Update
End With
Else
With rs
.AddNew
![Epic_Title] = ws.Cells(i, 1).value
![Iteration_Assignment_Content] = ws.Cells(i, 2).value
![Iteration_id] = ws.Cells(i, 3).value
'Insert Record into Database
.Update
End With
End If
i = i + 1
Wend
'Close resultset
rs.Close
Set rs = Nothing
'
End Sub
The text in Bold is what is highlighted when I debug after getting the error "Run-time Error 3077 Syntax Error..." The weird thing is, I have the same code which works for the other sheets but not this work sheet.
Please please please can somebody help me?! Seen some pretty good responses to issues on here so thought to give this a try. So I basically have a macro button that updates a few tables in Access from a Spreadsheet in Excel. There are several sheets but just one sheet seems to be temperamental. I need the code to work so that it adds new records and updates old records. The code that I have is:
Sub Update_Epic_Iteration_Assignment(db As DAO.Database)
'
' Update EPIC_ITERATION_ASSIGNMENT table in i-log database from EPIC_ITERATION_ASSIGNMENT sheet
'
Dim ws As Worksheet
Dim rs As DAO.Recordset
'Select source spreadsheet
Set ws = ActiveWorkbook.Sheets("EPIC_ITERATION_ASSIGNMENT")
'loop through entries
i = 3
While (ws.Cells(i, 1).value <> "")
If rs Is Nothing Then
Set rs = db.OpenRecordset("EPIC_ITERATION_ASSIGNMENT", dbOpenDynaset)
End If
rs.FindFirst ("Epic_Title=" & ws.Cells(i, 1).value)
If Not rs.NoMatch Then 'Record exists
With rs
.Edit
![Iteration_Assignment_Content] = ws.Cells(i, 2).value
![Iteration_id] = ws.Cells(i, 3).value
'Update Record into Database
.Update
End With
Else
With rs
.AddNew
![Epic_Title] = ws.Cells(i, 1).value
![Iteration_Assignment_Content] = ws.Cells(i, 2).value
![Iteration_id] = ws.Cells(i, 3).value
'Insert Record into Database
.Update
End With
End If
i = i + 1
Wend
'Close resultset
rs.Close
Set rs = Nothing
'
End Sub
The text in Bold is what is highlighted when I debug after getting the error "Run-time Error 3077 Syntax Error..." The weird thing is, I have the same code which works for the other sheets but not this work sheet.