Output from DAO recordset

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gord

    Output from DAO recordset

    Me again,

    I'm new to Access and am self teaching from a couple of books, so bear with
    me. (I've got a little experience with Visual Basic)

    As I understand so far, if I want to perform a bunch of calculations on a
    set of records (not calculated fields, but doing calculations from records
    to record) using Visual Basic I would first create a DAO.recordset object
    with the records I want to play around with.

    Assuming I've got the first part right how do I go about outputting the
    results of my calculations?

    I'll use a rough example to explain:

    I've got a table (or query) of three records with field headers A B C & D
    sitting nicely in a DAO recordset. Using VB I add the values of records 1
    and 2 of field B and then divide by the contents of the third record in
    field D (crazy I know, but this is just to illustrate that I'm generating
    some brand new data that I want to display). I then want to display an
    output of the contents of record 3, fields A B & C and then the results of
    my calculations in a fourth column. I might also want to create completely
    brand new field headings as well for this new 'record'.

    Would I create a blank recordset to use in code in which to pass this info
    into? If so, how do you create a blank recordset that doesn't refer to any
    existing object? To what object would I most likely output my info to?
    (I'm assuming a report. If so, can I create a 'blank' report and manually
    set the field headings?

    This may be an awful lot to answer on in complete detail but if I could at
    least get a general direction to study on would be appreciated. I'm trying
    to make a database for my own purposes and would like to actually start
    creating something useful without having to 'hit the books' for months
    before I could accomplish something meaningful. In time I hope to educate
    myself a lot more on Access but it would be nice to get something going in
    the meantime.

    Thanks,

    Gord


  • Keith Wilby

    #2
    Re: Output from DAO recordset

    "Gord" <x1gord1x@telus .netwrote in message
    news:vKxhk.1175 $%b7.696@edtnps 82...
    >
    I've got a table (or query) of three records with field headers A B C & D
    sitting nicely in a DAO recordset. Using VB I add the values of records 1
    and 2 of field B and then divide by the contents of the third record in
    field D (crazy I know, but this is just to illustrate that I'm generating
    some brand new data that I want to display). I then want to display an
    output of the contents of record 3, fields A B & C and then the results of
    my calculations in a fourth column. I might also want to create
    completely brand new field headings as well for this new 'record'.
    >
    You can do it using a calculated field in a query and have your code in a
    function. Pass your parameters to the function from the query.

    MyCalcField: MyFunction(A,B, C)

    But you could do the calc in the query without using any code so I'm not
    sure what you'd achieve.

    Keith.


    Comment

    • timmg

      #3
      Re: Output from DAO recordset

      Since it sounds like you're going for a report as the final
      destination it makes sense to base that report on a table.

      In addition to you calculations your code can
      1) empty the table
      2) Insert the calculation results as new records (or record)
      3) Display the report

      Another approach is to tag the calculations, usally by date, and just
      keep appending to the report table. that way you'll have an ongoing
      history of each run. In that case modify 3 above to apply the
      appropriate filter.

      hth,

      Tim Mills-Groninger

      On Jul 22, 10:40 pm, "Gord" <x1gor...@telus .netwrote:
      Me again,
      >
      I'm new to Access and am self teaching from a couple of books, so bear with
      me.  (I've got a little experience with Visual Basic)
      >
      As I understand so far, if I want to perform a bunch of calculations on a
      set of records (not calculated fields, but doing calculations from records
      to record) using Visual Basic I would first create a DAO.recordset object
      with the records I want to play around with.
      >
      Assuming I've got the first part right how do I go about outputting the
      results of my calculations?
      >
      I'll use a rough example to explain:
      >
      I've got a table (or query) of three records with field headers A B C & D
      sitting nicely in a DAO recordset.  Using VB I add the values of records 1
      and 2 of field B and then divide by the contents of the third record in
      field D  (crazy I know, but this is just to illustrate that I'm generating
      some brand new data that I want to display).  I then want to display an
      output of the contents of record 3, fields A B & C and then the results of
      my calculations in a fourth column.  I might also want to create completely
      brand new field headings as well for this new 'record'.
      >
      Would I create a blank recordset to use in code in which to pass this info
      into?  If so, how do you create a blank recordset that doesn't refer toany
      existing object?  To what object would I most likely output my info to?
      (I'm assuming a report.  If so, can I create a 'blank' report and manually
      set the field headings?
      >
      This may be an awful lot to answer on in complete detail but if I could at
      least get a general direction to study on would be appreciated.  I'm trying
      to make a database for my own purposes and would like to actually start
      creating something useful without having to 'hit the books' for months
      before I could accomplish something meaningful.  In time I hope to educate
      myself a lot more on Access but it would be nice to get something going in
      the meantime.
      >
      Thanks,
      >
      Gord

      Comment

      • paii, Ron

        #4
        Re: Output from DAO recordset


        "Gord" <x1gord1x@telus .netwrote in message
        news:vKxhk.1175 $%b7.696@edtnps 82...
        Me again,
        >
        I'm new to Access and am self teaching from a couple of books, so bear
        with
        me. (I've got a little experience with Visual Basic)
        >
        As I understand so far, if I want to perform a bunch of calculations on a
        set of records (not calculated fields, but doing calculations from records
        to record) using Visual Basic I would first create a DAO.recordset object
        with the records I want to play around with.
        >
        Assuming I've got the first part right how do I go about outputting the
        results of my calculations?
        >
        I'll use a rough example to explain:
        >
        I've got a table (or query) of three records with field headers A B C & D
        sitting nicely in a DAO recordset. Using VB I add the values of records 1
        and 2 of field B and then divide by the contents of the third record in
        field D (crazy I know, but this is just to illustrate that I'm generating
        some brand new data that I want to display). I then want to display an
        output of the contents of record 3, fields A B & C and then the results of
        my calculations in a fourth column. I might also want to create
        completely
        brand new field headings as well for this new 'record'.
        >
        Would I create a blank recordset to use in code in which to pass this info
        into? If so, how do you create a blank recordset that doesn't refer to
        any
        existing object? To what object would I most likely output my info to?
        (I'm assuming a report. If so, can I create a 'blank' report and manually
        set the field headings?
        >
        This may be an awful lot to answer on in complete detail but if I could at
        least get a general direction to study on would be appreciated. I'm
        trying
        to make a database for my own purposes and would like to actually start
        creating something useful without having to 'hit the books' for months
        before I could accomplish something meaningful. In time I hope to educate
        myself a lot more on Access but it would be nice to get something going in
        the meantime.
        >
        Thanks,
        >
        Gord
        >
        >
        You should be able to bind you query or table to a report, then group by
        whatever field you use to select record 1 and 2. Display your calculation in
        the group footer. If grouping will not work look into sub reports. As for
        field headings use the On-Format event of the section to change headings
        based on the data.


        Comment

        Working...