-
Jul 3rd, 2001, 06:54 AM
#1
Thread Starter
Lively Member
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
-
Jul 3rd, 2001, 06:57 AM
#2
Addicted Member
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
-
Jul 3rd, 2001, 07:01 AM
#3
Thread Starter
Lively Member
how do i set the datasource of a report? is that the WHERE clause part of the DoCmd.OpenReport function?
thanks, PJ
-
Jul 3rd, 2001, 07:44 AM
#4
Addicted Member
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
-
Jul 3rd, 2001, 07:50 AM
#5
Thread Starter
Lively Member
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
-
Jul 3rd, 2001, 09:19 AM
#6
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|