Hello:
I am trying to write a code that will delete all records found in my DAO recordset Below is the code I have so far:
[code=vb]
'Procdure to give the user the ability to delete all records
'for a predefined recordset from the tblStaticAllFor ecast table
LockSQL = "SELECT * FROM tblStaticAllFor ecast WHERE" & _
" DivisionIDFK = " & Val(Me.cboDivis ion.Value) & _
" And WrkRegIDFK = " & Val(Me.cboWrkRe g.Value) & _
" And CreditRegIDFK = " & Val(Me.cboCredi tReg.Value) & _
" And YearID = " & Val(Me.CboYear. Value) & _
" And MonthID = " & Val(Me.CboMonth .Value) & _
" And FWeek = " & Val(Me.cboWeek. Value)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenR ecordset(LockSQ L)
recordexists = rst.RecordCount
'If no records are found
If recordexists = 0 Then
MsgBox "There are no records to delete."
Else
rst.MoveLast 'Move to last record
rst.MoveFirst 'Move to First record
If MsgBox("The number of records you are about to delete is " & recordexists & "." & _
" Click the ok button to proceed", vbOKCancel, vbDefaultButton 2) = vbOK Then
'code will delete the records that the user has selected.
End If
End If
End Sub
[/code]
Is there a quick code that would do this?
Keith.
I am trying to write a code that will delete all records found in my DAO recordset Below is the code I have so far:
[code=vb]
'Procdure to give the user the ability to delete all records
'for a predefined recordset from the tblStaticAllFor ecast table
LockSQL = "SELECT * FROM tblStaticAllFor ecast WHERE" & _
" DivisionIDFK = " & Val(Me.cboDivis ion.Value) & _
" And WrkRegIDFK = " & Val(Me.cboWrkRe g.Value) & _
" And CreditRegIDFK = " & Val(Me.cboCredi tReg.Value) & _
" And YearID = " & Val(Me.CboYear. Value) & _
" And MonthID = " & Val(Me.CboMonth .Value) & _
" And FWeek = " & Val(Me.cboWeek. Value)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenR ecordset(LockSQ L)
recordexists = rst.RecordCount
'If no records are found
If recordexists = 0 Then
MsgBox "There are no records to delete."
Else
rst.MoveLast 'Move to last record
rst.MoveFirst 'Move to First record
If MsgBox("The number of records you are about to delete is " & recordexists & "." & _
" Click the ok button to proceed", vbOKCancel, vbDefaultButton 2) = vbOK Then
'code will delete the records that the user has selected.
End If
End If
End Sub
[/code]
Is there a quick code that would do this?
Keith.
Comment