-
totally remove the focus from a subform
Hello all,
I have a form with a subform. When certain conditions are met I want all
of the controls on the subform to become disabled. Problem is, I cannot totally
remove the focus from the subform to allow the code to disable the controls.
(There is always one control left with the focus and nowhere to place it.)
Any ideas on how to totally remove (suspend) the focus from the subform so
that I can disable all of the controls. (Or suspend the focus from any form
for the same purpose for that matter.)
Thanks aaron
-
Re: totally remove the focus from a subform
Hi Aaron
It would help if you said what your programming environment was, but as you
mentioned subforms I'll assume you're working in Access.
You can do it this way
Command6 is a CommandButton on the Subform and form2 is the ControlName of
the Subform control on the Main form
Private Sub Command6_Click()
Me.Parent!Text0.SetFocus
Me.Parent!form2.Enabled = False
End Sub
regards
Ian
** invalid email address, change dk to denmark
homepage http://www.kingsoft-denmark.com/
aaron <arelyea@home.com> wrote in message news:395d36b6$1@news.devx.com...
>
> Hello all,
> I have a form with a subform. When certain conditions are met I want all
> of the controls on the subform to become disabled. Problem is, I cannot
totally
> remove the focus from the subform to allow the code to disable the
controls.
> (There is always one control left with the focus and nowhere to place
it.)
> Any ideas on how to totally remove (suspend) the focus from the subform so
> that I can disable all of the controls. (Or suspend the focus from any
form
> for the same purpose for that matter.)
> Thanks aaron
-
Re: totally remove the focus from a subform
"Ian King" <advice@kingsoft-dk.com> wrote:
>Hi Aaron
>
>It would help if you said what your programming environment was, but as
you
>mentioned subforms I'll assume you're working in Access.
>
>You can do it this way
>
>Command6 is a CommandButton on the Subform and form2 is the ControlName
of
>the Subform control on the Main form
>
>Private Sub Command6_Click()
>Me.Parent!Text0.SetFocus
>Me.Parent!form2.Enabled = False
>End Sub
>
>regards
>
>Ian
>
>** invalid email address, change dk to denmark
>
>homepage http://www.kingsoft-denmark.com/
>
>
>aaron <arelyea@home.com> wrote in message news:395d36b6$1@news.devx.com...
>>
>> Hello all,
>> I have a form with a subform. When certain conditions are met I want
all
>> of the controls on the subform to become disabled. Problem is, I cannot
>totally
>> remove the focus from the subform to allow the code to disable the
>controls.
>> (There is always one control left with the focus and nowhere to place
>it.)
>> Any ideas on how to totally remove (suspend) the focus from the subform
so
>> that I can disable all of the controls. (Or suspend the focus from any
>form
>> for the same purpose for that matter.)
>> Thanks aaron
>
>
You are correct. After reading my post I realize I left out a couple of
important points. I am using Access but let me explain further. The subform
only has text boxes. I need to be able to disable all of the textboxes yet
leave the subform control enabled. I need to leave the subform control enabled
to allow the user to scroll up/down, left/right in the subform. But the individual
text boxes need to be disabled to prevent data editing. Of course the problem
is that if I have nowhere to send the focus to (all text boxes are to be
disabled) and I get an error message telling me that I cannot set the last
textbox's enabled property to false because it has the focus. Trick is ,
I have nowhere else to set the focus on the subform. Vicious circle.
I have changed the application to get around this but I am still wondering
if it is possible to do what I am suggesting for future projects.
Thank you for your initial response.
Aaron
-
Re: totally remove the focus from a subform
OK, try this
drop an unbound TextBox on the subform and set its
TabStop = False
Left = 0
Top = 0
Height = 0
Width = 0
and set the focus to this, then you can set all the other textboxes's
Enabled to false.
regards
Ian
** invalid email address, change dk to denmark
homepage http://www.kingsoft-denmark.com/
aaron <arelyea@home.com> wrote in message news:395fb1cc$1@news.devx.com...
<snip>
> You are correct. After reading my post I realize I left out a couple of
> important points. I am using Access but let me explain further. The
subform
> only has text boxes. I need to be able to disable all of the textboxes yet
> leave the subform control enabled. I need to leave the subform control
enabled
> to allow the user to scroll up/down, left/right in the subform. But the
individual
> text boxes need to be disabled to prevent data editing. Of course the
problem
> is that if I have nowhere to send the focus to (all text boxes are to be
> disabled) and I get an error message telling me that I cannot set the last
> textbox's enabled property to false because it has the focus. Trick is ,
> I have nowhere else to set the focus on the subform. Vicious circle.
>
> I have changed the application to get around this but I am still wondering
> if it is possible to do what I am suggesting for future projects.
>
> Thank you for your initial response.
>
> Aaron
-
Re: totally remove the focus from a subform
Hi again
Even better
Sub form's code
Dim ctl As Control
'Set focus to any control on the Parent form
Me.Parent!<control name>.SetFocus
For Each ctl In Me.Controls
If TypeOf ctl Is TextBox Then ctl.Enabled = False
Next
regards
Ian
** invalid email address, change dk to denmark
homepage http://www.kingsoft-denmark.com/
Ian King <advice@kingsoft-dk.com> wrote in message
news:395fe6d7@news.devx.com...
> OK, try this
>
> drop an unbound TextBox on the subform and set its
>
> TabStop = False
> Left = 0
> Top = 0
> Height = 0
> Width = 0
>
> and set the focus to this, then you can set all the other textboxes's
> Enabled to false.
>
>
> regards
>
> Ian
>
> ** invalid email address, change dk to denmark
>
> homepage http://www.kingsoft-denmark.com/
>
>
> aaron <arelyea@home.com> wrote in message news:395fb1cc$1@news.devx.com...
> <snip>
> > You are correct. After reading my post I realize I left out a couple of
> > important points. I am using Access but let me explain further. The
> subform
> > only has text boxes. I need to be able to disable all of the textboxes
yet
> > leave the subform control enabled. I need to leave the subform control
> enabled
> > to allow the user to scroll up/down, left/right in the subform. But the
> individual
> > text boxes need to be disabled to prevent data editing. Of course the
> problem
> > is that if I have nowhere to send the focus to (all text boxes are to be
> > disabled) and I get an error message telling me that I cannot set the
last
> > textbox's enabled property to false because it has the focus. Trick is
,
> > I have nowhere else to set the focus on the subform. Vicious circle.
> >
> > I have changed the application to get around this but I am still
wondering
> > if it is possible to do what I am suggesting for future projects.
> >
> > Thank you for your initial response.
> >
> > Aaron
>
>
-
Re: totally remove the focus from a subform
Hello,
Thanks for the suggestions, Ian King. The first one looks like a pretty good
work around but the second one brings up another question, if you have the
time.
I tried approaching it from the angle you describe in your second suggestion
but it didn't seem to work for me. From what I could gather, and this might
be my general misunderstanding, it seemed that every form and subform retains
its own focus. So even though I would set the focus to a control on the parent
form, when I would go about disabling the controls on the subform (using
a method very similar to yours) I would still get an error message telling
me that I could not disable a control on the subform that had the focus.
Well, after trying that for a while I concluded that even though I had set
the focus to a control on the parent form, the subform must still retain
it's own focus 'position'. Is that correct? Or was something else happening
that I was misunderstanding? (I don't actually expect a response as to what
could have been happening to lead me to my conclusion, only if anyone happens
to know the answer to the larger question about each form retaining it's
own focus 'position'.)
I thank anyone in advance that chooses to respond.
"Ian King" <advice@kingsoft-dk.com> wrote:
>Hi again
>
>Even better
>
>Sub form's code
>
>Dim ctl As Control
>'Set focus to any control on the Parent form
>Me.Parent!<control name>.SetFocus
>For Each ctl In Me.Controls
> If TypeOf ctl Is TextBox Then ctl.Enabled = False
>Next
>
>regards
>
>Ian
>
>** invalid email address, change dk to denmark
>
>homepage http://www.kingsoft-denmark.com/
>
>
>Ian King <advice@kingsoft-dk.com> wrote in message
>news:395fe6d7@news.devx.com...
>> OK, try this
>>
>> drop an unbound TextBox on the subform and set its
>>
>> TabStop = False
>> Left = 0
>> Top = 0
>> Height = 0
>> Width = 0
>>
>> and set the focus to this, then you can set all the other textboxes's
>> Enabled to false.
>>
>>
>> regards
>>
>> Ian
>>
>> ** invalid email address, change dk to denmark
>>
>> homepage http://www.kingsoft-denmark.com/
>>
>>
>> aaron <arelyea@home.com> wrote in message news:395fb1cc$1@news.devx.com...
>> <snip>
>> > You are correct. After reading my post I realize I left out a couple
of
>> > important points. I am using Access but let me explain further. The
>> subform
>> > only has text boxes. I need to be able to disable all of the textboxes
>yet
>> > leave the subform control enabled. I need to leave the subform control
>> enabled
>> > to allow the user to scroll up/down, left/right in the subform. But
the
>> individual
>> > text boxes need to be disabled to prevent data editing. Of course the
>> problem
>> > is that if I have nowhere to send the focus to (all text boxes are to
be
>> > disabled) and I get an error message telling me that I cannot set the
>last
>> > textbox's enabled property to false because it has the focus. Trick
is
>,
>> > I have nowhere else to set the focus on the subform. Vicious circle.
>> >
>> > I have changed the application to get around this but I am still
>wondering
>> > if it is possible to do what I am suggesting for future projects.
>> >
>> > Thank you for your initial response.
>> >
>> > Aaron
>>
>>
>
>
-
Re: totally remove the focus from a subform
Hi Aaron
I've uploaded a demo Acc97 mdb to
http://pc.freediskspace.com/Folders/453028
you need this password to access the folder - fileapps, and the file you
want is Disable.zip
regards
Ian
** invalid email address, change dk to denmark
homepage http://www.kingsoft-denmark.com/
aaron <arelyra@home.com> wrote in message news:3960df2d$1@news.devx.com...
>
> Hello,
> Thanks for the suggestions, Ian King. The first one looks like a pretty
good
> work around but the second one brings up another question, if you have the
> time.
>
> I tried approaching it from the angle you describe in your second
suggestion
> but it didn't seem to work for me. From what I could gather, and this
might
> be my general misunderstanding, it seemed that every form and subform
retains
> its own focus. So even though I would set the focus to a control on the
parent
> form, when I would go about disabling the controls on the subform (using
> a method very similar to yours) I would still get an error message telling
> me that I could not disable a control on the subform that had the focus.
>
>
> Well, after trying that for a while I concluded that even though I had set
> the focus to a control on the parent form, the subform must still retain
> it's own focus 'position'. Is that correct? Or was something else
happening
> that I was misunderstanding? (I don't actually expect a response as to
what
> could have been happening to lead me to my conclusion, only if anyone
happens
> to know the answer to the larger question about each form retaining it's
> own focus 'position'.)
>
> I thank anyone in advance that chooses to respond.
>
>
> "Ian King" <advice@kingsoft-dk.com> wrote:
> >Hi again
> >
> >Even better
> >
> >Sub form's code
> >
> >Dim ctl As Control
> >'Set focus to any control on the Parent form
> >Me.Parent!<control name>.SetFocus
> >For Each ctl In Me.Controls
> > If TypeOf ctl Is TextBox Then ctl.Enabled = False
> >Next
> >
> >regards
> >
> >Ian
> >
> >** invalid email address, change dk to denmark
> >
> >homepage http://www.kingsoft-denmark.com/
> >
> >
> >Ian King <advice@kingsoft-dk.com> wrote in message
> >news:395fe6d7@news.devx.com...
> >> OK, try this
> >>
> >> drop an unbound TextBox on the subform and set its
> >>
> >> TabStop = False
> >> Left = 0
> >> Top = 0
> >> Height = 0
> >> Width = 0
> >>
> >> and set the focus to this, then you can set all the other textboxes's
> >> Enabled to false.
> >>
> >>
> >> regards
> >>
> >> Ian
> >>
> >> ** invalid email address, change dk to denmark
> >>
> >> homepage http://www.kingsoft-denmark.com/
> >>
> >>
> >> aaron <arelyea@home.com> wrote in message
news:395fb1cc$1@news.devx.com...
> >> <snip>
> >> > You are correct. After reading my post I realize I left out a couple
> of
> >> > important points. I am using Access but let me explain further. The
> >> subform
> >> > only has text boxes. I need to be able to disable all of the
textboxes
> >yet
> >> > leave the subform control enabled. I need to leave the subform
control
> >> enabled
> >> > to allow the user to scroll up/down, left/right in the subform. But
> the
> >> individual
> >> > text boxes need to be disabled to prevent data editing. Of course the
> >> problem
> >> > is that if I have nowhere to send the focus to (all text boxes are to
> be
> >> > disabled) and I get an error message telling me that I cannot set the
> >last
> >> > textbox's enabled property to false because it has the focus. Trick
> is
> >,
> >> > I have nowhere else to set the focus on the subform. Vicious circle.
> >> >
> >> > I have changed the application to get around this but I am still
> >wondering
> >> > if it is possible to do what I am suggesting for future projects.
> >> >
> >> > Thank you for your initial response.
> >> >
> >> > Aaron
> >>
> >>
> >
> >
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks