Results 1 to 6 of 6

Thread: DoCmd.OpenReport in VB program?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Posts
    98

    DoCmd.OpenReport in VB program?

    hi, i am trying to open an Access report using a VB program, but i want the report to open to a record specified by the user so that when i print the report, the only pages printed will be the report for that record only. i can open the entire report, but this includes all of the records.

    thanks for help in advance, PJ

  2. #2
    Addicted Member reznor's Avatar
    Join Date
    May 2001
    Location
    Netherlands
    Posts
    151
    What you have to do is let the user set the criteria so you can select one record. Build the query as a string in code and set that SQL select string as the datasource of the report.
    "Computers are incredibly fast, accurate and stupid. Human beings are incredibly slow, inaccurate and brilliant. Together they are powerful beyond imagination." - Albert Einstein

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Posts
    98
    how do i set the datasource of a report? is that the WHERE clause part of the DoCmd.OpenReport function?

    thanks, PJ

  4. #4
    Addicted Member reznor's Avatar
    Join Date
    May 2001
    Location
    Netherlands
    Posts
    151
    Are you building this in Access or in VB?
    I used to build applications in Access, but now I build new apps in VB. I don't even know if you can do a Docmd.Openreport from VB. I know that's what I used in Access, but I don't even know how to access a report in Access from VB.

    In Access you can do something like this yes:
    Code:
    DoCmd.Openreport "rptPerson", acViewPreview, "qryPeople", "Name = '" & txtName.text & "'"
    hope my Access code isn't that rusty
    "Computers are incredibly fast, accurate and stupid. Human beings are incredibly slow, inaccurate and brilliant. Together they are powerful beyond imagination." - Albert Einstein

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Posts
    98
    i am doing it in VB. i can use the DoCmd.OpenReport part in VB to open the total report of every record, but i don't know how to open just one.

    thanks

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jun 2001
    Posts
    98
    i found out how to do it using the RecordSource function. here it is:

    acc_app.DoCmd.OpenReport "Report_name", acViewDesign
    acc_app.Reports("Report_name").RecordSource = "SELECT * FROM Table_name WHERE Field_name = '" & user_entry_variable & "'"

    thanks for the help,
    PJ

Posting Permissions

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



Click Here to Expand Forum to Full Width