Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make ADO.recordset updatable

Status
Not open for further replies.

Pampers

Technical User
Apr 7, 2004
1,300
AN
Hi everyone,
I use the following code to generate a recordset (ADO) in the afterupdate-event of a combox (passing a parameter to a view) to populate a (single) form. It works ok, except that recordset is not updatable (the uniquetable property is set - if I make the view the recordsource of the form, the view is updatable). I think I have to set CursorType and Locktype, but don't how. Any tips?

Code:
Private Sub FilterVoyage_AfterUpdate()
   Dim Cmd As ADODB.Command
   Dim rs As ADODB.Recordset
   Dim cn As ADODB.Connection
    
   Set Cmd = New ADODB.Command
   Set rs = New ADODB.Recordset

 
   With Cmd
      .CommandText = "vwTest"
      .CommandType = adCmdUnknown
Set prm = .CreateParameter("VoyageID", adInteger, adParamInput)
      .Parameters.Append prm
      .Parameters("VoyageID") = Me.FilterVoyage
      .ActiveConnection = CurrentProject.Connection
      Set rs = .Execute
End With

Set Me.Recordset = rs

End Sub

Pampers [afro]
Just back from holiday...
that may it explain it.
 
Can you help with with opening a table via ado? I can't seem to figure out the syntax.

Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

Set cnn = CurrentProject.Connection
Set rst = cnn.Open("tbl_exports")

My cnn.open(BLA) statment keeps giving me an error telling me its expecting a variable, or something else. I want to open the recordset and update a field value....

I live to work and I work to live.
 
try this:

Code:
    Dim rs As ADODB.Recordset
     
    Set rs = New ADODB.Recordset
    Set rs.ActiveConnection = CurrentProject.Connection
    rs.Open "tbl_exports", , adOpenDynamic, adLockOptimistic
    Set Me.Recordset = rs

Pampers [afro]
Just back from holiday...
that may it explain it.
 

Set rs = New ADODB.Recordset

With rs
.CursorLocation= adUseClient ' adUseServer
.CursroType = adOpenStatic ' adOpenKeyset
.LockType = adLockOptimistic
End With

With cmd
...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top