Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2003
    Location
    Rotterdam
    Posts
    17

    Question Unanswered: create unbound recordset with ado

    Can somebody tell me, is it possible te create an ado recordset (in an access project) thas is not bound to a table or query. This ado recordset is the input for an access report.
    Peter Dorsman

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    Uh... yeah, when you open the dataset you can pass command text to it.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Yes you can. Here is some sample code:

    Code:
    Dim cn as ADODB.Connection
    Dim rs as ADODB.Recordset
    
    Set cn = new ADODB.Connection
    cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Password=TestPass;Data Source=C:\Test.mdb;Persist Security Info=False;Exclusive=0"
    cn.open
    
    set rs = new ADODB.recordset
    rs.ActiveConnection = cn
    rs.Open "SELECT * FROM Table1"
    
    rs.Close
    cn.Close
    Set rs=Nothing
    Set cn = Nothing
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  4. #4
    Join Date
    Oct 2003
    Location
    Rotterdam
    Posts
    17
    Sirocco,

    Thank you for your answer, but I think I was not clear enough with my question. What I want is to create a new recordset, define new columns and there properties and put values in it. Al this without creating a new table in the sql database.

    I’ve found examples of this on the internet, but the were for Web Application. I’m working with an Access project and like to show the results of the input in the recordset in an access report.
    Peter Dorsman

  5. #5
    Join Date
    Oct 2003
    Location
    Rotterdam
    Posts
    17

    Unhappy Alomst there

    I've almost solved my problem, but am stuck with the last part. I use this code on the Open event of my access Report

    Private Sub Report_Open(Cancel As Integer)

    'open rs
    Dim rsrap As ADODB.Recordset
    Set rsrap = CreateObject("ADODB.Recordset")

    'create fields
    rsrap.fields.Append "field1", adInteger
    rsrap.fields.Append "field2", adInteger
    rsrap.fields.Append "field3", adInteger
    rsrap.fields.Append "field4", adInteger
    rsrap.fields.Append "field5", adInteger
    rsrap.fields.Append "field6", adInteger
    rsrap.fields.Append "field7", adVarChar, 50

    'put values in the fields
    rsrap.Open

    While x < 10

    rsrap.AddNew

    rsrap(0) = x
    rsrap(1) = x + 1
    rsrap(2) = x + 2
    rsrap(3) = x + 3
    rsrap(4) = x + 4
    rsrap(5) = x + 5
    rsrap(6) = "tekst" & x

    rsrap.Update

    x = x + 1

    Wend

    Set Me.Recordset = rsrap

    On the report are 7 fields with the controlsource named "field1", "field2", ect.
    The report is showing 10 record but in every fields the value "fault". What shoud I do to let the report show the values that are in the recordset.
    Peter Dorsman

  6. #6
    Join Date
    Feb 2011
    Posts
    2
    Have you solved this? I'd love to know too.

    Eric

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •