VBA to Open a Form

Hunter O.

Registered User.
Local time
Yesterday, 23:03
Joined
Oct 11, 2004
Messages
11
Hello,

I am trying to use VBA attached to a command button in another piece of software to open just a form of an Access database.
Here is the code that I have copied into VBA and this works fine except it shows everything including the form.
Any help in modifying the code to just show just the form with everything else hidden/minimized would be appreciated.
I have my database set to open on the form at start up.

Sub test()
sDBFILE = "C:\thermoforming\database test.mdb"
Set objAccess = CreateObject("Access.Application")
objAccess.Application.Visible = True
objAccess.Application.RunCommand 10
objAccess.OpenCurrentDatabase sDBFILE
End Sub

Thanks,
Hunter
 
Here is how I am currently doing this
Primary DB.
A sub that takes the PATH\DBNAME as a parameter in strPath

Set appAccess = CreateObject("Access.Application")
appAccess.DoCmd.Quit ' Safty end if running curent instance
With appAccess
.OpenCurrentDatabase strPath
.Visible = True
DoEvents
.Run "OutsideControl", Trim(Str(Flag)) ' Sub to run in new instance and parameters
End With

In the new instance DB this is the sub that receives the call.
Sub OutsideControl(Flag As Integer)
Select Case Flag
Case 101
DoCmd.RunMacro "Outside1"
Case 102
DoCmd.RunMacro "Outside2"
Case 103
DoCmd.RunMacro "Outside3"
Case 104
DoCmd.RunMacro "Outside4"
Case 105
DoCmd.RunMacro "Outside5"
Case Else
DoCmd.RunMacro "OutsideError"
Exit Sub
End Select
End Sub

Hope that helps
 
FoFa,

Thanks for the reply and sorry it has taken this long to get back.
I am new to using VBA and I’m lost with the code you mentioned above. I have read about a sw_hide command but have not figured out how or where to use it.
Thanks Again

Hunter
 
In the initial DB this line: .Run "OutsideControl", Trim(Str(Flag)) ' Sub to run in new instance and parameters
opens the Other DB and runs a SUB (in this case) called OutsideControl.
So of course you need a SUB in the Other DB called OUTSIDECONTROL. In my example I pass a value to it (101-105) that tells this sub which MACRO to run to do whatever function it is suppose to do. In this case it is an archive DB and opens certain forms or reports based on the requirements.
 

Users who are viewing this thread

Back
Top Bottom