Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Bind ADO Recordset to Form


Message #1 by merciermd@t... on Wed, 17 Oct 2001 22:16:53
I'm hoping someone can help me with this dilemma.



I?m using Access 2000 Projects with a SQL Server database. I have a form 

connected to a very large table, so I don?t want the form to return all 

rows in the database, it should start with an empty form.



What I want to do is let the user specify which parent record to load and 

have the form load all the child records, but I don?t want to stay 

connected to the database. When the user clicks on the button to load the 

records, I create an updateable client side ADO connection and recordset. 

Then I want to bind the form to this recordset object so that I can do 

batch updates when the user clicks on the save button.



I have no problems creating the disconnected recordset, and it is 

updateable. The problem is when I set the form recordset to my recordset 

object, the form is read-only. I have a book from MS Press that says it is 

possible to bind a form to an ADO recordset and have it read/write. I also 

have an article from MSDN that says you can bind an ADO recordset to a 

form but it will only be read-only. Who?s right, the left or right 

hand!!!!!



I find it hard to believe that this can?t be done.



This is the code I?m using in my form.





Option Compare Database

Option Explicit



Dim rst as ADODB.Recordset



Private Sub cmdLoad_Click()

   

   Dim con        As New ADODB.Connection

   Dim strcon     As String

   

   Set rst = Nothing

   

   strcon = "Provider=SQLOLEDB.1;Persist Security Info=False;" & _

            "User ID=sa;Password=;Initial Catalog=Some Data;Data 

Source=Some Server"

   

   ' Create and Open the conection object.

   con.CursorLocation = adUseClient

   con.Open strcon

   

   ' Create and Open the Recordset object.

   rst.CursorLocation = adUseClient

   rst.CursorType = adOpenStatic

   rst.LockType = adLockBatchOptimistic

   rst.Open ?Some Stored Procedure", con, , , adCmdStoredProc

   

   ' Bind the Recordset to the form.

   Set Me.Recordset = rst

   Me.UniqueTable = "Some Table"

   

   ' Disconnect the Recordset from the database.

   Set rst.ActiveConnection = Nothing

   con.Close

   Set con = Nothing

       

End Sub



Private Sub Form_Load()

   Set rst = New ADODB.Recordset

End Sub

Message #2 by "Mike McCrossin" <mike_mccrossin@h...> on Thu, 18 Oct 2001 06:04:32 -0700
Hi Mercier,



What is the MSDN article you have and what is the book you are using.



that is all for now...Mike

 


  Return to Index