ShowWindow SetForegroundWindow in Access2007 RT

S

Sam

Hi - Not sure where best to post Q.
I am maintain old code. Was running in Acc2000 RT. Now need to run in
Acc2007 RT.

Acc2007 RT gives "Execution of this application has stopped due to a
run-time error"
I've pinned down the error to the below statements (lots of msgbox's) in my

If I comment out the below calls, everything works fine. BUT, the below
calls was helping to provide control over a) showing the report control form
- listing available reports;
b) and the Print/Print Preview of the report - so when I select the Close
button, the report form shows.

In Acc2007 RT, with the below stmts commented out, I have to find and select
the Print Preview Close button for the report form to show.

Is there a better way to do what I need? My goal:
1) show report form
2) select report from form and show print preview
3) select an obvious Close button (Acc2000 used to display one vs the upper
right X)
4) show the report form

TIA
Sam

=== code not liked by Access 2007 RT =====
Private Sub Form_Open(Cancel As Integer)
Dim ObjAccess As Object
Dim strPath As String

'[strPath result = full path to a reports.mdb - works fine]

'Failing Call 1
Set ObjAccess = GetObject(strPath)
Call SetForegroundWindow(ObjAccess.hWndAccessApp)
Forms!report_manager.Visible = True

End Sub

Private Sub Command32_Click()
Dim ObjAccess As Object
Dim strPath As String

'[strPath result = full path to a reports.mdb - works fine]
'Failing Call 2
Set ObjAccess = GetObject(strPath)
Call ShowWindow(ObjAccess.hWndAccessApp, SW_SHOWMAXIMIZE)

End Sub
 
E

Evi

Bet this is missing references.
I have Access 2000 and found that code about Objects didn't work in one
database.

Here are the references which I have which finally made it work.

Visual Basic For applications

Microsoft Access 9.0 Object Library

Microsoft DAO 3.6

OLE Automation

Microsoft ActiveX Data Objects 2.1 Library

Microsoft Visual Basic For Applications Extensibility 5.3

Microsoft Forms 2.0 Object Library



The last one did the trick. It wasn't in the list of references in Access,
instead I had to Browse to find FM20.dll in the References window.



You will probably have another Object Library in XP rather than 9.0 but that
doesn't seem to make a difference.



Evi



..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top