Does a textbox have to have a name reference, or can I use a wildc

E

efandango

Tina,

sorry, I misintepreted what you meant by 'ActiveControl'; I though you meant
the name of my last ActiveControl. I wasn't aware that it referred to a
literal expression.

Well, it worked a treat.

Thank you for your help (and patience) with my problem. It is greatly
appreciated.

Eric



tina said:
did you try

Screen.PreviousControl.Form.ActiveControl

and if so, what happened?

hth


efandango said:
OK, I now understand.

It worked with this line:

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" &
Screen.PreviousControl.Form.Run_point_Venue


but it promtps me to ask the question of how I can have this button as a
universal button, where 'PreviousControl' simply refers to the last control
that the user was in just before pressing the button?, if I have to name the
actual control. It seems to contradict (my understanding) of the
PreviousControl feature, where I thought the code would 'know' what
PreviousControl I was in.


tina said:
As you suggested, I have tried this line for the button (I hope I
understood
what you mean by activecontrol, which I took to be the form that the
button
is on):

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" &
Screen.PreviousControl.Form.frm_Runs & ""

no, in the code i posted, ActiveControl refers to the control *on the
subform* that had the focus before the command button on the mainform was
clicked. from the example code you posted much earlier in this thread, i
believe that would be control Run_point_Venue on subform frm_Points.

what we're hoping is that the expression

Screen.PreviousControl.Form.ActiveControl

will provide the same reference as

Forms![frm_Runs].[frm_Points].Form![Run_point_Venue]

where Screen = frm_Runs, PreviousControl = frm_Points.Form, and
ActiveControl = Run_point_Venue.

hth


yes, those two forms are set as the SourceObject of subform
controls within the mainform; what I meant was that they are not linked by
any Child relationships. But I now understand specifically what people
mean
by a subform.


As you suggested, I have tried this line for the button (I hope I
understood
what you mean by activecontrol, which I took to be the form that the
button
is on):

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" &
Screen.PreviousControl.Form.frm_Runs & ""

but still get the same error message.

this occurs under the condtions that you mentioned whereby the user is in
a
control on a subform and immediately goes straight to the button and
presses
it. I understand what you mean about it being an assumption on the part of
the suer interaction, but given the way this database works, and what the
button is for, it's not really as big an asumption as you may imagine.


:

comments inline.

Tina,

Apologies for the delay in coming back to you; I have been
experiencing
problems accessing this forum.

no problem. btw, if you're using the website interface, you might
consider
using a newsreader instead, such as Outlook Express.


Yes, you are correct about the control being outside of the main form,
it
is
actually on the Form Header of the mainform.

if you mean that the command button is in the Header section of the
mainform, then it's in the mainform - not outside of it.


The button is called: btn_Google_It2
it is on my main form header: frm_Runs

The textbox controls are located on various forms

two of the most significant forms are called:

frm_Point_2_Point_A
frm_Point_2_Point_B

Though these are on a tab page (of the main form - frm_Runs), they are
not
actual true subforms (not need).

if the two forms listed above are set as the SourceObject of subform
controls within the mainform, then they're subforms, period. it doesn't
matter whether or not their RecordSources are linked to the RecordSource
of
the mainform - they're still subforms.

so i'd guess that the problem is that using "PreviousControl" isn't
working
because the code is called from a command button on the mainform; when
you
click the button, the "previous control" was the subform control (the
control in the mainform that "holds" the subform form object). give the
following a try as your reference:

Screen.PreviousControl.Form.ActiveControl

the above code assumes that the control in the subform has the focus,
and
then the user clicks directly on the command button in the mainform,
without
moving to another control in the subform first, AND without moving to
another control in the mainform before clicking the command button.
those
seem like pretty big assumptions to me; i'll refer you back to my first
post
in this thread.


There are a few other forms that I would like to access from the
1-button,
but for now I'll wait until I can get this first example working.


good idea ;)



:

Forms![frm_Runs].[frm_Points].Form![Run_point_Venue]

the above code refers to a subform (frm_Points) of a mainform
(frm_Runs),
from *outside both forms*. where are the textbox controls located?
and
where
is the command button located? both answers will have a bearing on
the
correct syntax needed, and on how we might incorporate
Screen.PreviousControl to help work out a solution.

hth


Thanks for that advice; but I'm still having a problem.

This is the line I used to use.

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" &
Forms![frm_Runs].[frm_Points].Form![Run_point_Venue] & ", " &
"London, "

This is what I want to use:

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" & Screen.PreviousControl
&
",London"

How can I incorporate this?


:


where current text box is just the actual text box that I
happen
to be
clicking from

you're not clicking from a text box, you're clicking on a
command
button.
so, assuming that the user will ALWAYS first set focus to the
textbox
control that s/he wants to refer to in the google search,
immediately
before
clicking the command button, you can replace the specific
control
reference
with

Screen.PreviousControl

but you must consider whether the above assumption is a
reasonable
assumption to make for your users.

hth


message
Ok, I wasn't sure how to title this thread; but here's the
question.

I have a button that when clicked will go to google and search
on
whatever
is in the text box. So far , so good.

But I would really like to use this button for other text
boxes,
but I
don't
want a different button for each text box name reference

So, instead of something like: (partial code)


Private Sub btn_Google_it_Click()

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" & [Run_point_Venue]

End Sub


Can I have something like:

So, instead of something like: (partial code)


Private Sub btn_Google_it_Click()

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" & Me.current text box

End Sub
 
T

tina

you're very welcome, Eric, glad to hear it worked. this reference was new
territory for me too, had never tried it before, so we both learned a little
bit. :)


efandango said:
Tina,

sorry, I misintepreted what you meant by 'ActiveControl'; I though you meant
the name of my last ActiveControl. I wasn't aware that it referred to a
literal expression.

Well, it worked a treat.

Thank you for your help (and patience) with my problem. It is greatly
appreciated.

Eric



tina said:
did you try

Screen.PreviousControl.Form.ActiveControl

and if so, what happened?

hth


efandango said:
OK, I now understand.

It worked with this line:

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" &
Screen.PreviousControl.Form.Run_point_Venue


but it promtps me to ask the question of how I can have this button as a
universal button, where 'PreviousControl' simply refers to the last control
that the user was in just before pressing the button?, if I have to
name
the
actual control. It seems to contradict (my understanding) of the
PreviousControl feature, where I thought the code would 'know' what
PreviousControl I was in.


:

As you suggested, I have tried this line for the button (I hope I
understood
what you mean by activecontrol, which I took to be the form that the
button
is on):

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" &
Screen.PreviousControl.Form.frm_Runs & ""

no, in the code i posted, ActiveControl refers to the control *on the
subform* that had the focus before the command button on the
mainform
was
clicked. from the example code you posted much earlier in this thread, i
believe that would be control Run_point_Venue on subform frm_Points.

what we're hoping is that the expression

Screen.PreviousControl.Form.ActiveControl

will provide the same reference as

Forms![frm_Runs].[frm_Points].Form![Run_point_Venue]

where Screen = frm_Runs, PreviousControl = frm_Points.Form, and
ActiveControl = Run_point_Venue.

hth


yes, those two forms are set as the SourceObject of subform
controls within the mainform; what I meant was that they are not linked by
any Child relationships. But I now understand specifically what people
mean
by a subform.


As you suggested, I have tried this line for the button (I hope I
understood
what you mean by activecontrol, which I took to be the form that the
button
is on):

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" &
Screen.PreviousControl.Form.frm_Runs & ""

but still get the same error message.

this occurs under the condtions that you mentioned whereby the
user is
in
a
control on a subform and immediately goes straight to the button and
presses
it. I understand what you mean about it being an assumption on the part of
the suer interaction, but given the way this database works, and
what
the
button is for, it's not really as big an asumption as you may imagine.


:

comments inline.

Tina,

Apologies for the delay in coming back to you; I have been
experiencing
problems accessing this forum.

no problem. btw, if you're using the website interface, you might
consider
using a newsreader instead, such as Outlook Express.


Yes, you are correct about the control being outside of the
main
form,
it
is
actually on the Form Header of the mainform.

if you mean that the command button is in the Header section of the
mainform, then it's in the mainform - not outside of it.


The button is called: btn_Google_It2
it is on my main form header: frm_Runs

The textbox controls are located on various forms

two of the most significant forms are called:

frm_Point_2_Point_A
frm_Point_2_Point_B

Though these are on a tab page (of the main form - frm_Runs),
they
are
not
actual true subforms (not need).

if the two forms listed above are set as the SourceObject of subform
controls within the mainform, then they're subforms, period. it doesn't
matter whether or not their RecordSources are linked to the RecordSource
of
the mainform - they're still subforms.

so i'd guess that the problem is that using "PreviousControl" isn't
working
because the code is called from a command button on the
mainform;
when
you
click the button, the "previous control" was the subform control (the
control in the mainform that "holds" the subform form object).
give
the
following a try as your reference:

Screen.PreviousControl.Form.ActiveControl

the above code assumes that the control in the subform has the focus,
and
then the user clicks directly on the command button in the mainform,
without
moving to another control in the subform first, AND without
moving
to
another control in the mainform before clicking the command button.
those
seem like pretty big assumptions to me; i'll refer you back to
my
first
post
in this thread.


There are a few other forms that I would like to access from the
1-button,
but for now I'll wait until I can get this first example working.


good idea ;)



:

Forms![frm_Runs].[frm_Points].Form![Run_point_Venue]

the above code refers to a subform (frm_Points) of a mainform
(frm_Runs),
from *outside both forms*. where are the textbox controls located?
and
where
is the command button located? both answers will have a
bearing
on
the
correct syntax needed, and on how we might incorporate
Screen.PreviousControl to help work out a solution.

hth


Thanks for that advice; but I'm still having a problem.

This is the line I used to use.

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" &
Forms![frm_Runs].[frm_Points].Form![Run_point_Venue] & ", " &
"London, "

This is what I want to use:

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" & Screen.PreviousControl
&
",London"

How can I incorporate this?


:


where current text box is just the actual text box that I
happen
to be
clicking from

you're not clicking from a text box, you're clicking on a
command
button.
so, assuming that the user will ALWAYS first set focus
to
the
textbox
control that s/he wants to refer to in the google search,
immediately
before
clicking the command button, you can replace the specific
control
reference
with

Screen.PreviousControl

but you must consider whether the above assumption is a
reasonable
assumption to make for your users.

hth


message
Ok, I wasn't sure how to title this thread; but here's the
question.

I have a button that when clicked will go to google
and
search
on
whatever
is in the text box. So far , so good.

But I would really like to use this button for other text
boxes,
but I
don't
want a different button for each text box name reference

So, instead of something like: (partial code)


Private Sub btn_Google_it_Click()

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" & [Run_point_Venue]

End Sub


Can I have something like:

So, instead of something like: (partial code)


Private Sub btn_Google_it_Click()

stAppName = "C:\Program Files\Internet Explorer\iexplore.exe
http://www.google.co.uk/search?hl=en&q=" & Me.current
text
box
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top