View Single Post
  #6 (permalink)  
Old December 18th, 2005, 04:53 AM
Bob Bedell Bob Bedell is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi sfx,

Since this appears to be Von’s only post to this forum ever (gem that it is), mind if I share my two cents? I was under the impression that this couldn’t be done, so I found it quite interesting. Of course, it turns out to be quite simple.

I created a table (in a .mdb) with two fields, DataID and DataItem, and added a few records. Then created a form and placed two text box controls (Text1 and Text2) on it. I set the form’s Default View property to Continuous Form, and left all other form properties alone. Then I typed DataID in Textbox1’s Control Source property, and DataItem in Textbox2’s Control Source property, leaving all other textbox properties alone. Then I placed the following in the form’s Load Event:

Private Sub Form_Load()
    Dim cnn As ADODB.Connection
    Dim rst As ADODB.Recordset

    Set cnn = CurrentProject.Connection
    Set rst = New ADODB.Recordset

    Dim strSQL As String
    strSQL = "SELECT * FROM tblData"

    rst.Open strSQL, cnn, adOpenKeyset, adLockOptimistic, adCmdText

    Set Me.Form.Recordset = rst

End Sub

The continuos form populates as advertised.

The only observation I might add is that this only works with a Keyset or Static cursor, which suggests that the recordset needs to be able to report exactly how many records it contains. Dynamic or ForwardOnly cursors return a run-time error.

Thanks for revisiting this.

Bob


Reply With Quote