K
kidkarma
Hi, I'm an undergraduate who's trying to learn Access, Excel and
correspondingly VBA as well.(hasn;t been easy)
Using Access as a database that is updated fortnightly from an excel
sheet.
The macro is supposed to pick out whether the details have been
uploaded(by matching staffname and date) and if it matches, to Delete
the old records of that particular staffmmember.
However, at the moement its hitting a
'run time error -
'syntax error(missing operator) in query expression 'tblData Where
StaffName = mystaff'
Code:
If rst("StaffName") = mystaff Then
If rst("Date") = startDate Then
response2 = MsgBox("You have already uploaded your details to the
database for this period. Do you want to replace previous
information?", vbYesNo)
End If
End If
If response2 = vbNo Then
ActiveWorkbook.Close
MsgBox "Data upload not performed"
End If
If response2 = vbYes Then
'will delete old data
With New ADODB.Connection
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MyConn
.Execute "DELETE tblData Where StaffName = " & mystaff
rst.Update
.Close
End With
End If
Call sendto_managers2
Appreciate any help with this!
correspondingly VBA as well.(hasn;t been easy)
Using Access as a database that is updated fortnightly from an excel
sheet.
The macro is supposed to pick out whether the details have been
uploaded(by matching staffname and date) and if it matches, to Delete
the old records of that particular staffmmember.
However, at the moement its hitting a
'run time error -
'syntax error(missing operator) in query expression 'tblData Where
StaffName = mystaff'
Code:
If rst("StaffName") = mystaff Then
If rst("Date") = startDate Then
response2 = MsgBox("You have already uploaded your details to the
database for this period. Do you want to replace previous
information?", vbYesNo)
End If
End If
If response2 = vbNo Then
ActiveWorkbook.Close
MsgBox "Data upload not performed"
End If
If response2 = vbYes Then
'will delete old data
With New ADODB.Connection
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open MyConn
.Execute "DELETE tblData Where StaffName = " & mystaff
rst.Update
.Close
End With
End If
Call sendto_managers2
Appreciate any help with this!