Re: Code Help
From: Wayne Morgan (comprev_gothroughthenewsgroup_at_hotmail.com)
Date: 05/26/04
- Next message: anonymous_at_discussions.microsoft.com: "Re: HOVER TECHNIQUE"
- Previous message: Fred Boer: "Re: Code Help"
- In reply to: Patti: "Code Help"
- Next in thread: Patti: "Re: Code Help"
- Reply: Patti: "Re: Code Help"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 26 May 2004 09:19:12 -0500
> Set rs = New DAO.Recordset
> rs.Open "SequenceNumbersAssigned", CurrentProject.Connection,
adOpenDynamic,
> adLockOptimistic
You need to combine these.
Set rs = CurrentDb.OpenRecordset("SequenceNumbersAssigned", dbOpenDynamic,,
dbOptimistic)
It appears that you may be mixing DAO and ADO syntax.
-- Wayne Morgan MS Access MVP "Patti" <MrsT@SPAM_NOT.com> wrote in message news:e%23GNYqyQEHA.1388@TK2MSFTNGP09.phx.gbl... > 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 > > > >
- Next message: anonymous_at_discussions.microsoft.com: "Re: HOVER TECHNIQUE"
- Previous message: Fred Boer: "Re: Code Help"
- In reply to: Patti: "Code Help"
- Next in thread: Patti: "Re: Code Help"
- Reply: Patti: "Re: Code Help"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|