What's my current field?

  • Thread starter Thread starter grep
  • Start date Start date
G

grep

How do you determine your current field?

I'm writing some code that will, at some point, disable the current
control. I'd like to check the current control and, if it is the one I'm
disabling, change focus to a different control.

So it would look something like this:

If <current_control> = Command68 then
docmd.gotocontrol Command69
Command68.Enable = False
end if

How do I do that?

grep
 
grep said:
How do you determine your current field?

I'm writing some code that will, at some point, disable the current
control. I'd like to check the current control and, if it is the one I'm
disabling, change focus to a different control.

So it would look something like this:

If <current_control> = Command68 then
docmd.gotocontrol Command69
Command68.Enable = False
end if


If Me.ActiveControl.Name = "Command68" then
Command69.SetFocus
Command68.Enable = False
End If
 
How do you determine your current field?

I'm writing some code that will, at some point, disable the current
control. I'd like to check the current control and, if it is the one I'm
disabling, change focus to a different control.

So it would look something like this:

If <current_control> = Command68 then
docmd.gotocontrol Command69
Command68.Enable = False
end if

How do I do that?

grep

If the code is behind the current control then:

Screen.ActiveControl.Name

However, if your code is in a command button's click event and you are
referring to a text control that the cursor was in just before you
click the command button, then use

Screen.PreviousControl.Name
 
Sorry, but this isn't making sense to me. The Active control is the one that
already has the focus, so going to it is not necessary, you are already there.
In addition, the code form you are using is not in common use any longer.
The better way to make a control the active control is to use the SetFocus
method:

Me.SomeControl.SetFocus
 
Thanks to both of you - I got it now.
If the code is behind the current control then:

Screen.ActiveControl.Name

However, if your code is in a command button's click event and you are
referring to a text control that the cursor was in just before you
click the command button, then use

Screen.PreviousControl.Name
 
Thanks Dave, I was wondering that myself...

Klatuu said:
Sorry, but this isn't making sense to me. The Active control is the one
that
already has the focus, so going to it is not necessary, you are already
there.
In addition, the code form you are using is not in common use any longer.
The better way to make a control the active control is to use the SetFocus
method:

Me.SomeControl.SetFocus
 
Back
Top