Cannot use SetFocus method

G

Guest

I have the following code in my form. (The form is the Main Menu with 3
labels that act as menu selections.) I want the first label to get the focus
when the form is opened (or loaded, or active, etc.)

Private Sub Form_Open(Cancel As Integer)
Me.lblViewInv.SetFocus
End Sub

When I compile, I get an error message "Method or data member not found."
I've tried different variations of the statement, resulting in various
errors. Is it a library thing? I'm using VB for Apps, MS Access 11.0 Object
Libray, MS DAO 3.6 Object Library, OLE Automation, MS VB for Apps Ext. 5.3,
and MS Office XP Web Components.

Thanks in advance.
 
S

Stefan Hoffmann

hi Dorci,
Private Sub Form_Open(Cancel As Integer)
Me.lblViewInv.SetFocus
End Sub

When I compile, I get an error message "Method or data member not found."
I've tried different variations of the statement, resulting in various
errors. Is it a library thing?
No, it must be a typo. Have you an Option Explicit at the beginning of
your module?

You may also change the activation order on your form, take a look at
context menu while being in the design view of the form.


mfG
--> stefan <--
 
G

Guest

Bummer! I was hoping that wasn't the problem. The only things on the form
are labels disguised as command buttons. I'm using labels instead of command
buttons because they're prettier. I'll forgo setting the focus, but at least
now I know. Thanks so much for your prompt response.
 
B

BruceM

I think you can use a text box to take the place of a command button, same
as a label. I used to use labels as command buttons in some cases, but now
I place pictures of command buttons (downloaded from the web) on the command
buttons when I need something other than basic gray. They have a gray
border, but it is easier to work with them than with labels. A search of
the web should turn up a number of free download options if you wish to go
that way.
 
D

Dirk Goldgar

In
Dorci said:
Bummer! I was hoping that wasn't the problem. The only things on
the form are labels disguised as command buttons. I'm using labels
instead of command buttons because they're prettier. I'll forgo
setting the focus, but at least now I know.

You could cover each label with a transparent command button, and
SetFocus to the command button. You'd have to either put code in the
command buttons' Click events to call the corresponding label's Click
event procedure, or else just move the labels' Click code to the command
buttons.
 

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