Log in

View Full Version : Set Focus Problem



AlanAnderson
11-12-2012, 11:52 AM
Hi, I have a simple form and, depending on certain conditions want to get the cursor to jump to a certain field.

The following code, copied straight from books etc does not work!

What am I doing wrong. I have detailed the error messages on the lines involved.

Regards

Alan

Private sub txtIncExc_Click()
If me.txtIncExc = “E” Then
Me.TranStandard.Enabled=True ‘ Compile error : method or data member not found
Me.TranTotal.SetFocus ‘ Error 438 Object doesn’t support this property or method
Etc……
:banghead:

Tommy
11-12-2012, 02:07 PM
me.txtIncExc

me is short for the form name that currently has the focus.
txtIncExc is the name of the control.
so to setfocus on it you say

me.txtIncExc.setfocus

The control that gets focus I think should be a textbox, Listbox, combobox, command button.

Me.TranStandard.Enabled=True

This look like it should be the .Visible property but I don't know what control it is.

AlanAnderson
11-12-2012, 10:58 PM
Hi All,
Problem solved. What it was is that I had an error in my field names so although above error messages seemed to point at setfocus and enabled the commands were fine - just my error in field names.

Thanks

Alan