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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.OpenForm not working

Status
Not open for further replies.

hal8000

Programmer
Sep 26, 2000
19
US
I am trying to open a form in Access which is a pivot table. I have read where the acDialog property should keep the form open but no matter what I do it just flashes and closes. I have inserted a STOP after the OpenForm and it is indeed being generated correctly it just gets closed without the STOP there. Any ideas? I am running the code from MS Project. Any ideas are appreciated.

Here is the code:

Sub TestOpenForm()


Dim strFormName As String
Dim strDBName As String


strFormName = "QueryNoStart"


strDBName = "C:\Documents and Settings\jeffb.HAC\My
Documents\project3.mdb"


On Error GoTo TestOpenform_Err

' Create Automation object.
Dim objAccess As Object
Set objAccess = CreateObject("Access.Application")

' Open the database.
objAccess.OpenCurrentDatabase strDBName, False

objAccess.DoCmd.OpenForm strFormName, acFormPivotTable, , , ,
acDialog

' Close Microsoft Access session instance...
objAccess.Quit acExit

Set objAccess = Nothing
Exit Sub
TestOpenform_Err:
MsgBox Error$(), vbInformation, "Automation"

End Sub
 
erm, you're creating an acces application object, and then you are telling it to quit...

maybe you can try to not tell the object to quit...

--------------------
Procrastinate Now!
 
That was simple enough. I think I am blushing. I borrowed this code from a process that prints a report from Access and did not realize the full implication of that line. I do now. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top