Discussion Locked

VB6 to Access report using Automation

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

How to input FROM date and TO date from text box on VB form to text boxes on Access report, query data using Automation, ADO, ACCESS2000 database
To preview report I'm using code objAccess.DoCmd.OpenReport rptName acPreview, , strWhere. Criteria from VBform have to be placed in strWhere.

6 replies

by john_wills

Not to text boxes on the report but to labels. In the form's VBA assign the dates to public dates: parameter.EndDate:= me.EndDate
parameter.StartDate:= me.StartDate
in the report's Open event VBA:
me.EndDate.Caption:= parameter.EndDate
me.StartDate.Caption:=parameter.StartDate
The "caption" is not an option shown as you type, but it does get recognized.

by lilyleader

This code is not working. Parameter object in VB form has to be defined from proper parent object in ADO object model wich will connect to Parameter query on the ACCESS side thru Automation wich used in this case. Maybe in addition to ADO, I need to use DAO? I need the syntax wich will make possible to input parameters on VB form and print or preview ACCESS report with this parameters.

by john_wills

I meant that you should first define parameter; it seemed so obvious I did not say so.
public type param
EndDate AS date
StartDate AS date
end type

public parameter AS param

by lilyleader

Your proposed solution is not work. Did you test this solution?
I still need the help for this problem.

by john_wills

I use this technique frequently, so I suppose I have tested it within your meaning. To decide what is going wrong with your implementation I need to know just what does not work. By use of msgbox you should be able to tell whether the dates are getting to the parameter and whether they are getting from the parameter to the report. If you like you can send me code extracts by email, indicating which extract comes from the form, which from the report, and which from any other module.

This discussion is closed to new replies.