P
Patti
When I run the following code, I get a compile error "Invalid use of New
Keyword" and in the statement Set rs = New DAO.Recordset, the " New
DAO.Recordset" portion is highlighted. Can anyone tell me why?
I am testing this in 2002, but it needs to be compatible with '97. I do
have a DAO listed in References.
Private Sub CmdWriteToTable_Click()
Dim rs As DAO.Recordset
Dim i As Long
'Check if the entries are valid
If Not (IsNumeric(txtFirstSeqNum) And IsNumeric(txtLastSeqNum)) Then Exit
Sub
If txtFromNumber > txtToNumber Then Exit Sub
'Add the records to the table
Set rs = New DAO.Recordset
rs.Open "SequenceNumbersAssigned", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
For i = txtFirstSeqNum To txtLastSeqNum
rs.AddNew
rs!DateAssigned = txtDateAssigned ' (that is: rs!TableFieldName)
rs!Code = txtCode
rs!SeqNum = i
rs!Quant = txtQuant
rs.Update
Next i
rs.Close
Set rs = Nothing
End Sub
Keyword" and in the statement Set rs = New DAO.Recordset, the " New
DAO.Recordset" portion is highlighted. Can anyone tell me why?
I am testing this in 2002, but it needs to be compatible with '97. I do
have a DAO listed in References.
Private Sub CmdWriteToTable_Click()
Dim rs As DAO.Recordset
Dim i As Long
'Check if the entries are valid
If Not (IsNumeric(txtFirstSeqNum) And IsNumeric(txtLastSeqNum)) Then Exit
Sub
If txtFromNumber > txtToNumber Then Exit Sub
'Add the records to the table
Set rs = New DAO.Recordset
rs.Open "SequenceNumbersAssigned", CurrentProject.Connection, adOpenDynamic,
adLockOptimistic
For i = txtFirstSeqNum To txtLastSeqNum
rs.AddNew
rs!DateAssigned = txtDateAssigned ' (that is: rs!TableFieldName)
rs!Code = txtCode
rs!SeqNum = i
rs!Quant = txtQuant
rs.Update
Next i
rs.Close
Set rs = Nothing
End Sub