subfrm w. 2 buttons (setting not enable) - set focus problem!

vinzz

Registered User.
Local time
Today, 01:15
Joined
Apr 24, 2008
Messages
47
hello,

i've searched this forum for a sollustion but didn't find any. Here's my problem and some info about the actions:

1 - I have a continuous subfrm called 'FrmHfdPersUit' that has 2 buttons 'nieuw' (on subfrmheader) and 'bewerk' (in cont.form) and some textboxes which can not be selected (locked = true and enabled = false - off course setfocus wont work on these textboxes)
2- when the headform (called 'hoofdform') is editable the 2 buttons will be enabled. but when the headform is readonly (allowedits = false) the 2 buttons in the subfrm needs to be set 'enabled = false'
---> here occurs the error: 2164 cannot disable a control that has the focus
Debug lets me see that the first buttoncode 'nieuw.enabled = false executes but the second button 'bewerk' not.
Obviously access always needs one control on all forms where he can set a focus on because the focus is on a textbox (called datum_pv) on the headform.
Code:
....
            Me.SetFocus
        Me.Datum_pv.SetFocus
    With Me.FrmHfdPersUit.Form
        .Nieuw.Enabled = False
        .Bewerk.Enabled = False
    End With
....
Is there any chance that i can still disable the two buttons and leave the textbox properties as they are? Or do i have to set a transparent button without any code behind it to set the focus on? (don't like that :p)

I hope someone has an other solution for this?
 
Curious....If you're not partial to Tab Stops on in the SubForm, what happens if you set the Tab Stop property for each button to No?

I have come across this sort of situation may times and the solution I use is to hide a Text Box in the Form by setting its' Width property to 0, BackStyle property to Transparent, and the BorderStyle property to Transparent. Do Not set the Visible property to False.

Now setting focus to this TextBox control makes it appear that nothing in the Form has focus. The Text Box can also be used to store temp data from time t time.

Code:
With Me.FrmHfdPersUit.Form
   .MyHiddenTextBox.SetFocus
   .Nieuw.Enabled = False
   .Bewerk.Enabled = False
End With
.
 
i'm using a button with width & height = 0 and transparent button style atm. works the same as your solution.
A text box would indeed be better to use sometimes, I'll keep that in mind. I'm already using global declarations instead.
I was just curious if there's any other solution for this :(
 

Users who are viewing this thread

Back
Top Bottom