thick_guy_9
New member
- Local time
- Today, 02:41
- Joined
- Jun 21, 2009
- Messages
- 7
Hello all
As a one time VB programmer, I have been out of touch with VB and need to complete a project using VBa and access.
I need to delete a table "MDP". The problem is that after i do an EXECUTE on the currentDB, the rowsaffected property is = 0? But I have 6 rows in the table!! Please help !!
dim myrec as DAO.recordset
dim wrkcurrent as DAO.workspace
Set myRec = CurrentDb.OpenRecordset("MDP", dbOpenTable)
If Not (myRec.EOF And myRec.BOF) Then
myRec.MoveLast
iCnt = myRec.RecordCount
myRec.Close
Set myRec = Nothing
' truncate table if any records are found
If (iCnt <> 0) Then
Set wrkCurrent = DBEngine.Workspaces(0)
wrkCurrent.BeginTrans
sSQL = "DELETE * FROM MasterData_Plan;"
CurrentDb.Execute sSQL
End If
If iCnt <> CurrentDb.RecordsAffected Then
wrkCurrent.Rollback
Set wrkCurrent = Nothing
sErrorMsg = ""
sErrorMsg = "Not all rows were deleted from table MDP"
sErrorMsg = sErrorMsg & vbCrLf & "Loading Raw data into this table will terminate!"
sErrorTitle = Me.Form.Name & ": Error in cmdLoad_OnClick"
GoTo Error_Handler
End If
wrkCurrent.CommitTrans
Set wrkCurrent = Nothing
End If
As a one time VB programmer, I have been out of touch with VB and need to complete a project using VBa and access.
I need to delete a table "MDP". The problem is that after i do an EXECUTE on the currentDB, the rowsaffected property is = 0? But I have 6 rows in the table!! Please help !!
dim myrec as DAO.recordset
dim wrkcurrent as DAO.workspace
Set myRec = CurrentDb.OpenRecordset("MDP", dbOpenTable)
If Not (myRec.EOF And myRec.BOF) Then
myRec.MoveLast
iCnt = myRec.RecordCount
myRec.Close
Set myRec = Nothing
' truncate table if any records are found
If (iCnt <> 0) Then
Set wrkCurrent = DBEngine.Workspaces(0)
wrkCurrent.BeginTrans
sSQL = "DELETE * FROM MasterData_Plan;"
CurrentDb.Execute sSQL
End If
If iCnt <> CurrentDb.RecordsAffected Then
wrkCurrent.Rollback
Set wrkCurrent = Nothing
sErrorMsg = ""
sErrorMsg = "Not all rows were deleted from table MDP"
sErrorMsg = sErrorMsg & vbCrLf & "Loading Raw data into this table will terminate!"
sErrorTitle = Me.Form.Name & ": Error in cmdLoad_OnClick"
GoTo Error_Handler
End If
wrkCurrent.CommitTrans
Set wrkCurrent = Nothing
End If