excel vba to open access form...form won't stay visible

ExcelTard

New Member
Joined
Jun 18, 2013
Messages
8
I got this one from 101 ready to use macros. When I run it, it shows an instantaneous flash of the form, but then the form shuts down. Any suggestions?

Sub Macro95()


'Step 1: Declare your variables
Dim AC As Access.Application

'Step 2: Start Access and open the target database
Set AC = New Access.Application
AC.OpenCurrentDatabase _
("C:\Temp\Database171.accdb")

'Step 3: Open the target form and make Access visible
With AC
.DoCmd.OpenForm "DatabaseForm", acNormal
.Visible = True
End With

End Sub
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Can you please share how you fixed this problem. Thanks

Sure...I copied and pasted the code in the last reply in this thread...

http://www.mrexcel.com/forum/microsoft-access/673585-open-access-form-excel.html

This was the code I used from the thread, except I deleted the two lines with "shop floor data entry" bc I don't know what I'm doing and it didn't work with them in :)


Code:
[COLOR=#333333]Sub OpenAccess2()Dim ac As Object[/COLOR]
Dim str As StringOn Error Resume NextSet ac = GetObject(, "[COLOR=#417394]Access[/COLOR].Application")If ac Is Nothing ThenSet ac = GetObject("", "[COLOR=#417394]Access[/COLOR].Application")ac.OpenCurrentDatabase "N:\Fishbowl Databases\Labor Collection Min.accdb"'str = ac.CurrentDb.Properties("Shop Floor Data Entry")ac.DoCmd.Close 2, "Shop Floor Data Entry" 'or strac.DoCmd.OpenForm "Earned Hours_Cast"ac.UserControl = TrueSet ac = NothingEnd IfAppActivate "Microsoft [COLOR=#417394]Access[/COLOR]" </pre>[COLOR=#333333]End Sub[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,958
Members
449,200
Latest member
indiansth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top