Stop a tab control with vba

Jon123

Registered User.
Local time
Today, 18:44
Joined
Aug 29, 2003
Messages
668
I'm trying to stop a couple fields from being able to tab to based on other field value in a form. I have the following code but this didnt work.

Code:
Private Sub Step42_GotFocus()
    If Me.Step42.Locked = True Then
    Me.step43.SetFocus
End If
End Sub

I then tried this. but it still allowed the tab stops. How can I stop it?
Code:
   Me.Step42.Locked = True
              Me.dat18.Locked = True
              Me.dat19.Locked = True
              Me.dat20.Locked = True
              Me.Step42.TabStop = False
              Me.dat18.TabStop = False
              Me.dat19.TabStop = False
              Me.dat20.TabStop = False
 
Use the Enabled property for the control, both alone or together with the Locked property.
 
I have tried the (me.field. locked = true) with the me.field.enabled = false
and its still allows to field to get focus using the tab
 
Can you post a zip of your database (remove anything private/confidential)?
 
The code does work as far as stopping a user from entering any data. So I have a box that covers a couple fields that is visible if data from another field makes it visible. So if its visible I want to stop the tab control from going to those fields to avoid what you see in the attachment.
 
sorry, having trouble with attaching
 

Attachments

I have tried the (me.field. locked = true) with the me.field.enabled = false
and its still allows to field to get focus using the tab
It works by me. :)
 
I think I may have figured it out. let me check something.
 
ya figured out what its doing but do not know how to fix it. So it would appear that if you use conditional formatting to change the field color based off its value then the code enable / locked will lock is so you can't enter data but the tab control will still go to that field. I really want to keep the conditional format is there anyway to fix this?

jon
 
We are talking about tab stop, aren't we and not about setting focus?
I've made a small example in the attached database with conditional format and have 3 buttons on a form which Enable/Unenable, Lock/Unlock and Set/Remove tab stop on the control RoleID, try the different settings by using tab and set focus.
If you still can't get it to work with the tab stop, then post a stripped version of your database with some sample data and the name of the form you have the problem (zip it).
 

Attachments

Users who are viewing this thread

Back
Top Bottom