G
ges via AccessMonster.com
Hi,
I have created a back out button. If my data to back out less than 9,500
records then it back out the whole thing, but if my data over 9,000 - 10,000
(most my file that need back out is over 15,000 records), it's stop around 9,
500 it did not finish the job, JUST STOP AND DOING NOTHING then I have to
click the button again to delete the rest ($5,500 records). Can anybody HELP
me? Thanks so much for any input!
Below are the code I created:
Private Sub cmdbtnBackOut_Click()
On Error GoTo Exit_cmdbtnBackOut
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim parmBatchNo As DAO.Parameter
Dim rstCollectionsInfo As DAO.Recordset
Dim strSQL As String
Dim intBatchNo As Integer
Dim Counter As Double
Dim RecsToDelete
Set dbs = CurrentDb
Set qdf = dbs.CreateQueryDef("")
strSQL = "PARAMETERS intBatchNumber INT; "
strSQL = strSQL & "SELECT tblCollectionsInfo.BatchNumber FROM
[tblCollectionsInfo] "
strSQL = strSQL & "WHERE ( ([BatchNumber] = [intBatchNumber] And
[BatchNumber] > 0) );"
qdf.SQL = strSQL
Set parmBatchNo = qdf.Parameters!intBatchNumber
intBatchNo = Int(Inputbox("Enter Batch Number of Records to Remove"))
parmBatchNo = intBatchNo
Debug.Print qdf.Parameters.Count
For Each parmBatchNo In qdf.Parameters
Debug.Print , parmBatchNo.Name, parmBatchNo.Type, parmBatchNo.Value
Next parmBatchNo
Set rstCollectionsInfo = qdf.OpenRecordset()
rstCollectionsInfo.MoveLast
RecsToDelete = rstCollectionsInfo.RecordCount
MsgBox "We have " & RecsToDelete & " records to delete."
DoCmd.Hourglass True
Counter = 0
Do Until rstCollectionsInfo.BOF
rstCollectionsInfo.Delete
rstCollectionsInfo.MovePrevious
Counter = Counter + 1
Loop
MsgBox "We have deleted " & Counter & " records."
qdf.Close
Exit_cmdbtnBackOut:
THANK YOU!
I have created a back out button. If my data to back out less than 9,500
records then it back out the whole thing, but if my data over 9,000 - 10,000
(most my file that need back out is over 15,000 records), it's stop around 9,
500 it did not finish the job, JUST STOP AND DOING NOTHING then I have to
click the button again to delete the rest ($5,500 records). Can anybody HELP
me? Thanks so much for any input!
Below are the code I created:
Private Sub cmdbtnBackOut_Click()
On Error GoTo Exit_cmdbtnBackOut
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim parmBatchNo As DAO.Parameter
Dim rstCollectionsInfo As DAO.Recordset
Dim strSQL As String
Dim intBatchNo As Integer
Dim Counter As Double
Dim RecsToDelete
Set dbs = CurrentDb
Set qdf = dbs.CreateQueryDef("")
strSQL = "PARAMETERS intBatchNumber INT; "
strSQL = strSQL & "SELECT tblCollectionsInfo.BatchNumber FROM
[tblCollectionsInfo] "
strSQL = strSQL & "WHERE ( ([BatchNumber] = [intBatchNumber] And
[BatchNumber] > 0) );"
qdf.SQL = strSQL
Set parmBatchNo = qdf.Parameters!intBatchNumber
intBatchNo = Int(Inputbox("Enter Batch Number of Records to Remove"))
parmBatchNo = intBatchNo
Debug.Print qdf.Parameters.Count
For Each parmBatchNo In qdf.Parameters
Debug.Print , parmBatchNo.Name, parmBatchNo.Type, parmBatchNo.Value
Next parmBatchNo
Set rstCollectionsInfo = qdf.OpenRecordset()
rstCollectionsInfo.MoveLast
RecsToDelete = rstCollectionsInfo.RecordCount
MsgBox "We have " & RecsToDelete & " records to delete."
DoCmd.Hourglass True
Counter = 0
Do Until rstCollectionsInfo.BOF
rstCollectionsInfo.Delete
rstCollectionsInfo.MovePrevious
Counter = Counter + 1
Loop
MsgBox "We have deleted " & Counter & " records."
qdf.Close
Exit_cmdbtnBackOut:
THANK YOU!