VBA to move move around in form

oravec

Board Regular
Joined
Apr 15, 2003
Messages
65
Hello,

I got the following code yesterday to open an Access file from Excel VBA. It works great. My next step is to close what I believe is a form that opens when file activates. Form has an "OK" button to close. Need to activate that button or "tab" three times then use "enter" key to close the form.


Thanks,
Cliff


Dim db As Access.Application
Sub test_opendb()

Set db = New Access.Application
db.OpenCurrentDatabase "c:\Program Files\opsnet\Opsnet20.mde"
db.Application.Visible = True

End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Have you tried using a close statement? I'm not sure if it would work from excel but I'd give it a shot. From the help menu:

The following example uses the Close method to close the form Order Review, saving any changes to the form without prompting:

DoCmd.Close acForm, "Order Review", acSaveYes

Dave
 
Upvote 0
Thanks,

That command works fine, but form must have a macro associated with the "OK" button that is not being activated with this method. Any way to automatically click "OK" button prior to closing form?

Cliff
 
Upvote 0
I'm not quite sure what the problem is, however, you should look in help under the sendkeys method. You can "send" specific keystrokes to program (like the tab control three times). It's very inefficient but it works.

Dave
 
Upvote 0

Forum statistics

Threads
1,221,551
Messages
6,160,460
Members
451,648
Latest member
SuziMacca

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