Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

Office automation - open a report in MS aAccess with VB6

I am using a vb6 front end form tied to a back end MSAccess 11 database. I want to programatically open the database, and open a report. The report will print an inovice, so it will need to be one specific record from the Orders table in the database. The OrderID is supplied at runtime from the vb6 form, and is used as the filter to open the report to the one specific record that I wish to see on the report.

Here is my code:

Dim appAccess As New Access.Application
Dim OrderID as Integer

appAccess.OpenCurrentDatabase C:\MyDB.mdb, True, "password"
appAccess.Visible = True
appAccess.DoCmd.OpenReport "rptInvoice", acViewPreview

rptInvoice is the report in Access. In the last line, after "acViewPreview", the next two parameters are "filter" and "WhereCondition". I need to know what to put in for the "WereCondition" that will convey to the Access database theOrderID on the VB6 form that is to match the "OrderID" in the Orders table of the database.

After I create a new instance of Access, I should have the ability to see all the objects and properties of the database. What I think I need to do is to find out how to reference the field 'OrderID' in the ' tblOrders'
of the database and put the value found in the txtOrderID text box on the vb6 form into the Where Condition of the DoCmd OpenReport statement.
0
M_Epstein
Asked:
M_Epstein
  • 2
2 Solutions
 
M_EpsteinAuthor Commented:
The first link refers to using snapshots, but that is not what I want to do.
the second link was much better. The solution was easier than I thought. I thought that I would have to access the table in my database as an object, and then set a criteria for the OrderID field within the table, but the problem was as simple as "OrderID = 12345" as the WhereCondition string. I actually found this post a week ago, but somehow missed the solution.

Thank you very much fo helping me solve my first question on EE!
0
 
M_EpsteinAuthor Commented:
This is essentially the same as the other solutions. My problem was that I was not using proper syntz for the where clause. Thank you all!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now