Good Morning World:
I have written the following code:
[code=vb]
'Gives the user to delete and replace all records for a specified parameter
LockSQL = "SELECT * FROM tblStaticAllFor ecast WHERE" & _
" DivisionIDFK = " & Val(Me.cboDivis ion.Value)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenR ecordset(LockSQ L)
recordexists = rst.RecordCount
MsgBox "The number of records you are about to delete is " & recordexists & "." & _
" Click the ok button to proceed", vbOKCancel, vbDefaultButton 2
If Nz(recordexists , 0) > 0 Then
'code will delete the records that the user has selected....... .......
End If
End If
End Sub
[/code]
Before I proceed with a code to delete the selected records from my "LockSQL" I wanted to make sure the count was correct. I know that I have 14 records in my tblStaticAllFor ecast that are all tagged with division set to value 2. So I should of recieved a count of 14 when I set the parameter in my form and ran my code, instead I got a count in my message box for 1. Does anybody know why that would happened? I ran a separate query via Access looking at the same parameters on the form and it got the correct count (14). Is somehow the count different when using a DAO recordset or is something wrong in my code??
Thanks for any thoughts,
Keith.
I have written the following code:
[code=vb]
'Gives the user to delete and replace all records for a specified parameter
LockSQL = "SELECT * FROM tblStaticAllFor ecast WHERE" & _
" DivisionIDFK = " & Val(Me.cboDivis ion.Value)
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenR ecordset(LockSQ L)
recordexists = rst.RecordCount
MsgBox "The number of records you are about to delete is " & recordexists & "." & _
" Click the ok button to proceed", vbOKCancel, vbDefaultButton 2
If Nz(recordexists , 0) > 0 Then
'code will delete the records that the user has selected....... .......
End If
End If
End Sub
[/code]
Before I proceed with a code to delete the selected records from my "LockSQL" I wanted to make sure the count was correct. I know that I have 14 records in my tblStaticAllFor ecast that are all tagged with division set to value 2. So I should of recieved a count of 14 when I set the parameter in my form and ran my code, instead I got a count in my message box for 1. Does anybody know why that would happened? I ran a separate query via Access looking at the same parameters on the form and it got the correct count (14). Is somehow the count different when using a DAO recordset or is something wrong in my code??
Thanks for any thoughts,
Keith.
Comment