Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd Not Showing Print Preview From VB/Access

Status
Not open for further replies.

TripleJHJO

Programmer
Jan 10, 2003
76
US
I am using VB6 to call an Access 2007 report. I am trying to show the report in print preview. The code executes, but does not show the report. If I change the acViewNormal parameter, the report prints a hard copy, so I know VB and Access work.

I have the following code:
Code:
    Dim MyAcc As New Access.Application
    
    MyAcc.OpenCurrentDatabase txtDbLoc.Text & "\job.mdb", True
    MyAcc.DoCmd.OpenReport "Loading Exception", acViewPreview, , "Job_number = 899"
    
    MyAcc.Quit
    
    Set MyAcc = Nothing

Any suggestions?

Thanks,

J.Jensen
 
try add these two lines before calling the report:

Dim MyAcc As New Access.Application

MyAcc.OpenCurrentDatabase txtDbLoc.Text & "\job.mdb", True
MyAcc.Visible = True
MyAcc.DoCmd.Maximize
MyAcc.DoCmd.OpenReport "Loading Exception", acViewPreview, , "Job_number = 899"

MyAcc.Quit

Set MyAcc = Nothing
 
Had to move the maximize statement to after the open report command, but it still didn't work.
Access opens and asks me to log into my workgroup, but closes right away.
 
This may solve the problem, i have a feeling its a little more complicated than this..

SendKeys "THE PASSWORD~"
MyAcc.OpenCurrentDatabase txtDbLoc.Text & "\job.mdb", True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top