how to press a button from a different form without sendkey

A

akko

Hi,

i want to replace the sendkeys{enter} function with something else cause
vista makes trouble.

i want to press a button from a different form without using sendkey.

any suggestions.

txs
akko
 
S

Scott McDaniel

Hi,

i want to replace the sendkeys{enter} function with something else cause
vista makes trouble.

i want to press a button from a different form without using sendkey.

In general, you'd be better off moving the code in that button to a Public Function (or Sub) and calling that function
in both your Button_Click and from your other forms. For example:

Sub MyButton_Click()
DoCmd.OpenForm "SomeFormName"
End Sub

Would become:

Public Function OpenMyForm()
DoCmd.OpenForm "SomeFormName"
End Function

And you'd then change the Click event to this:

Sub MyButton_Click()
OpenMyForm
End Sub

Other objects could then call this Function on your form:

Forms("NameOfFormWhere_OpenMyForm_Lives").OpenMyForm

The only caveat is the the form hosting the code MUST be open, otherwise the call will fail. If this is code that would
be used in many different places (and isn't specific to the form), then you might want to move it to a Standard Module,
which is always available to all objects.

Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
 

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