CreativeDavid
New member
- Local time
- Today, 22:49
- Joined
- Jan 26, 2020
- Messages
- 7
Long time reader of this forum, and had lots of help from people here so want to start out by thanking you all for your help. Believe it or not I have been able to get around near every single challenge with your help in past posts.
I have been making a kind of hybrid access mix. It is driven primarily by stored procedures I have built in SQL, and Access is acting as the forms interface and in this case report generator. This is working well for the most part and achieving great outcomes given how complex some of the queries are. Please I don't want to be drawn off into discussions on using pass through queries and so on, I have been working on this for many years and this is not my first iteration of this specific tool.
Todays challenge is I have a report that I am populating from the ADO recordset. I know this cant be done but I have worked around this limitation. The code works great as long as I load the report in Preview. The negative with this is someone has to push a button or click a mouse to print the report. When I change it to Normal and print the output manually as a PDF (I don't own a printer anymore) the report is blank. I guess I need to add a command to tell the report to print and then to close. But just in case someone here has a better idea...Here is the code:
As I said I can code to print and close and then move on, but it seems more likely there is a simpler solution.
I have been making a kind of hybrid access mix. It is driven primarily by stored procedures I have built in SQL, and Access is acting as the forms interface and in this case report generator. This is working well for the most part and achieving great outcomes given how complex some of the queries are. Please I don't want to be drawn off into discussions on using pass through queries and so on, I have been working on this for many years and this is not my first iteration of this specific tool.
Todays challenge is I have a report that I am populating from the ADO recordset. I know this cant be done but I have worked around this limitation. The code works great as long as I load the report in Preview. The negative with this is someone has to push a button or click a mouse to print the report. When I change it to Normal and print the output manually as a PDF (I don't own a printer anymore) the report is blank. I guess I need to add a command to tell the report to print and then to close. But just in case someone here has a better idea...Here is the code:
SQL:
Dim cmd As ADODB.Command
Dim rst As ADODB.Recordset
On Error GoTo cssRptLoad_ErrHandler:
Set rst = New ADODB.Recordset
Set cmd = New ADODB.Command
'Check connection is open
If gcn.State = 0 Then Call cssOpenConnection
cmd.ActiveConnection = gcn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "mysp_ProofofJobScott"
'Your parameters
cmd.Parameters("@StartJob").value = 1234
cmd.Parameters("@Cmonth").value = "February 2020"
Set rst = cmd.Execute
g_pFormName.cssRecord = rst
Do Until rst.EOF
DoCmd.OpenReport strReport, acViewPreview, , , acDialog, 1
'Wait if I need to add it. The above is a bit of a pain as someone has to be there
rst.MoveNext
Loop
Exit Sub
As I said I can code to print and close and then move on, but it seems more likely there is a simpler solution.
Last edited by a moderator: