an updateable recordset?

  • Thread starter Thread starter chancellor
  • Start date Start date
C

chancellor

Guest
I have the following code:
Dim rec As ADODB.Recordset
objword.Visible = True
Set rec = New ADODB.Recordset
rec.CursorType = 2
rec.LockType = 3
rec.CursorLocation = adUseClient

If ((tu1 = 2) Or (tu1) = 4) Then
With rec
.AddNew
.Fields("physician") = "fffff"
.Update
End With
End If

Unfortunately, the addnew command does not appear to be working. I'm trying to add "ffff" to the recordset already created elsewhere. However, this code replaces the first record in the recordset with "ffff". It does not add it to the recordset already in place. I've tried moving to the end of the recordset and adding but that does not appear to work either. Does anyone know which combination of cursor locations, lock types and cursortypes will allow me to add "ffff" to a recordset based on whether another variable has a certain value?
This truly has me stumped.
 
try it like this (plain and simple or are you planning on multiuser?):


dim myrs as object

set myrs = currentdb.openrecordset("Mytable or sql string")
myrs.addnew
myrs!myfield = "somevalue"
myrs!mysecondfield = 33215
myrs.update

myrs.close
set myrs = nothing
 
Last edited:

Users who are viewing this thread

Back
Top Bottom