Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DataReport - very easy question

Posted on 2002-07-02
4
Medium Priority
?
134 Views
Last Modified: 2010-05-02
Hello,

I want to print a DataReport, but the data that is printed there is NOT taken from a DB. Therefore, I don't have to specify DataSource and DataMember. However, VB requires it. How can I do that?

PS: This program doesn't use any DB file.
Please answer ASAP.

Thanks.
0
Comment
Question by:slavikn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Author Comment

by:slavikn
ID: 7124609
In order to do that I need a DataBase file, don't I? But I don't have any DB file. Any more suggestions?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 7124657
You don't need a database. You can create a new recordset object and fill it without any database.

dim x as new adodb.recordset

with x
   .cursorlocation = aduseclient
   .cursortype = adopenstatic
   .locktype = adlockbatchoptimistic
   with .fields
      .append "F1", adinteger
      .append "F2", advarchar, 40
   end with
   .open

   .addnew
   .fields("F1").value = 1
   .fields("F2").value = "value 1"
   .update

   .addnew
   .fields("F1").value = 2
   .fields("F2").value = "value 2"
   .update
end with
0
 
LVL 1

Author Comment

by:slavikn
ID: 7124802
Very good and helpful answer. Thanks.
I would use something shorter:

    ' Create a temporary Recordset
    Dim TempRS As New ADODB.Recordset
    With TempRS
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
        .LockType = adLockBatchOptimistic
        .Fields.Append "F1", adInteger
        .Open
    End With
    Set DataReport1.DataSource = TempRS

Thanks again.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question