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

E

efandango

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


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

tina

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


efandango said:
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


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

efandango

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


efandango said:
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


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

BruceM

As a suggestion, try using the double-click event of the specific text box
rather than a generic command button.

efandango said:
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


efandango said:
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


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

efandango

unfortunately, that feature option is already taken by another feature.



BruceM said:
As a suggestion, try using the double-click event of the specific text box
rather than a generic command button.

efandango said:
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


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


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

BruceM

Then maybe you can use the text box label double click event. To do this
you need to disassociate the label from the text box, otherwise it will not
have double-click event as an option. To disassociate the label, select it,
then press Ctrl + X to cut it, and Ctrl + V to paste it. Move it to where
it needs to be.

Regarding your question "How can I incorporate this", what happens when you
try?

efandango said:
unfortunately, that feature option is already taken by another feature.



BruceM said:
As a suggestion, try using the double-click event of the specific text
box
rather than a generic command button.

efandango said:
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


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


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

efandango

Bruce, I will look at the label option, thanks.

regards "what happens when I try"

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


but get error: 'Wrong number of arguments or invalid assignment'

it's the syntax that always foxes me...




BruceM said:
Then maybe you can use the text box label double click event. To do this
you need to disassociate the label from the text box, otherwise it will not
have double-click event as an option. To disassociate the label, select it,
then press Ctrl + X to cut it, and Ctrl + V to paste it. Move it to where
it needs to be.

Regarding your question "How can I incorporate this", what happens when you
try?

efandango said:
unfortunately, that feature option is already taken by another feature.



BruceM said:
As a suggestion, try using the double-click event of the specific text
box
rather than a generic command button.

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


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


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

efandango

regards, the label idea...

problem is, most of my text boxes don't have labels; and given the nature of
what I'm trying to achieve, eg: universal text box/button, having labels
would most likely confuse the issue, where there may be a form that does have
them and another that doesn't. It would be much neater if the user had a
consistant method to 'Google it' via the button.


BruceM said:
Then maybe you can use the text box label double click event. To do this
you need to disassociate the label from the text box, otherwise it will not
have double-click event as an option. To disassociate the label, select it,
then press Ctrl + X to cut it, and Ctrl + V to paste it. Move it to where
it needs to be.

Regarding your question "How can I incorporate this", what happens when you
try?

efandango said:
unfortunately, that feature option is already taken by another feature.



BruceM said:
As a suggestion, try using the double-click event of the specific text
box
rather than a generic command button.

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


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


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

BruceM

Does any variant of the code work (specifically, the one you had
originally)? The reason I ask is that it seems you are defining a string,
but then not doing anything with it. Or are you getting the error just in
attempting to set the value of stAppName?

If your original code works (despite its limitations), try adding this line
directly after it:

Debug.Print stAppName

Do the same with the other code (with Screen.PreviousControl).

Switch to the immediate window by pressing Ctrl + G. Compare the strings.

I have to admit I'm not sure why you are going through the IE executable
file. When I need to go to a hyperlink I use Application.FollowHyperlink.

efandango said:
Bruce, I will look at the label option, thanks.

regards "what happens when I try"

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


but get error: 'Wrong number of arguments or invalid assignment'

it's the syntax that always foxes me...




BruceM said:
Then maybe you can use the text box label double click event. To do this
you need to disassociate the label from the text box, otherwise it will
not
have double-click event as an option. To disassociate the label, select
it,
then press Ctrl + X to cut it, and Ctrl + V to paste it. Move it to
where
it needs to be.

Regarding your question "How can I incorporate this", what happens when
you
try?

efandango said:
unfortunately, that feature option is already taken by another feature.



:

As a suggestion, try using the double-click event of the specific text
box
rather than a generic command button.

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


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


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

efandango

yes, the original code works perfectly; and yes, it I am defining a string in
order that I can parse it to google. Bear in mind I have only posted the
significant line that is giving me problems; specifically with the
replacement version as Tina suggested, using 'Screen.PreviousControl'.

There is nothing wrong with the original code, but clearly there is
something wrong with the synax of the 2nd version, which is what I was hoping
someone could help me with.



BruceM said:
Does any variant of the code work (specifically, the one you had
originally)? The reason I ask is that it seems you are defining a string,
but then not doing anything with it. Or are you getting the error just in
attempting to set the value of stAppName?

If your original code works (despite its limitations), try adding this line
directly after it:

Debug.Print stAppName

Do the same with the other code (with Screen.PreviousControl).

Switch to the immediate window by pressing Ctrl + G. Compare the strings.

I have to admit I'm not sure why you are going through the IE executable
file. When I need to go to a hyperlink I use Application.FollowHyperlink.

efandango said:
Bruce, I will look at the label option, thanks.

regards "what happens when I try"

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


but get error: 'Wrong number of arguments or invalid assignment'

it's the syntax that always foxes me...




BruceM said:
Then maybe you can use the text box label double click event. To do this
you need to disassociate the label from the text box, otherwise it will
not
have double-click event as an option. To disassociate the label, select
it,
then press Ctrl + X to cut it, and Ctrl + V to paste it. Move it to
where
it needs to be.

Regarding your question "How can I incorporate this", what happens when
you
try?

unfortunately, that feature option is already taken by another feature.



:

As a suggestion, try using the double-click event of the specific text
box
rather than a generic command button.

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


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


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

BruceM

I can only bear in mind what you have posted.

I suggested Debug.Print. What were the results from that? If you compare
the two strings you can see where the second one (the one that doesn't work)
differs from the one that does work. If you post the difference I may be
able to suggest a way to get the correct string where that if failing now.

I did notice that the placement of commas in the "London" part of the string
are different in the two versions of the code. You have shown:
", " & "London,"
and
",London"

This will yield, respectively:
, London,
and
,London

You have posted working code (as I understand it) in two different ways:

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

Do both of these work? If so, you could just use the first (or better
perhaps, Me.Run_Point_Venue). If the second one works I'm a little
surprised, as I would have expected:
Forms![frm_Runs]![frm_Points].Form![Run_point_Venue]
(note the bang (exclamation mark) after frmRuns).


efandango said:
yes, the original code works perfectly; and yes, it I am defining a string
in
order that I can parse it to google. Bear in mind I have only posted the
significant line that is giving me problems; specifically with the
replacement version as Tina suggested, using 'Screen.PreviousControl'.

There is nothing wrong with the original code, but clearly there is
something wrong with the synax of the 2nd version, which is what I was
hoping
someone could help me with.



BruceM said:
Does any variant of the code work (specifically, the one you had
originally)? The reason I ask is that it seems you are defining a
string,
but then not doing anything with it. Or are you getting the error just
in
attempting to set the value of stAppName?

If your original code works (despite its limitations), try adding this
line
directly after it:

Debug.Print stAppName

Do the same with the other code (with Screen.PreviousControl).

Switch to the immediate window by pressing Ctrl + G. Compare the
strings.

I have to admit I'm not sure why you are going through the IE executable
file. When I need to go to a hyperlink I use
Application.FollowHyperlink.

efandango said:
Bruce, I will look at the label option, thanks.

regards "what happens when I try"

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


but get error: 'Wrong number of arguments or invalid assignment'

it's the syntax that always foxes me...




:

Then maybe you can use the text box label double click event. To do
this
you need to disassociate the label from the text box, otherwise it
will
not
have double-click event as an option. To disassociate the label,
select
it,
then press Ctrl + X to cut it, and Ctrl + V to paste it. Move it to
where
it needs to be.

Regarding your question "How can I incorporate this", what happens
when
you
try?

unfortunately, that feature option is already taken by another
feature.



:

As a suggestion, try using the double-click event of the specific
text
box
rather than a generic command button.

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


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

efandango

When I use the debug option on this line:

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

I just get the same error message box: 'Wrong number of arguments or invalid
assignment' when I click OK and hit ctrl+G, the intermediate window just
shows rows of digits like this:
-4.118957176925 3104.5170414771 -2463.19426220711



You have posted working code (as I understand it) in two different ways:

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


I don't quite understand this bit?, with regard to the first solo reference
[Run_point_Venue]

Unless you're referring to my very first post where I did mention that it is
partial code.

I also, don't know why you would be surprised if this line below does work,
but I have to say that I am really a novice at this, and don't always
understand why something does or does not work, and tend to rely on trial and
error:

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


However, this all seems to really digress from the point. Rather than
examine why working code actually works, I was hoping that I could discover
why non-working code doesn't work.

This is the actual 'complete' code line that works just fine:

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] & ", " &
Forms![frm_Runs].[frm_Points].Form.[Run_point_Address] & ", " & "London, " &
Forms![frm_Runs].[frm_Points].Form.Run_Point_Postcode

all I did was remove some of the references to make it easier to digest for
anyone reading it.




BruceM said:
I can only bear in mind what you have posted.

I suggested Debug.Print. What were the results from that? If you compare
the two strings you can see where the second one (the one that doesn't work)
differs from the one that does work. If you post the difference I may be
able to suggest a way to get the correct string where that if failing now.

I did notice that the placement of commas in the "London" part of the string
are different in the two versions of the code. You have shown:
", " & "London,"
and
",London"

This will yield, respectively:
, London,
and
,London

You have posted working code (as I understand it) in two different ways:

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

Do both of these work? If so, you could just use the first (or better
perhaps, Me.Run_Point_Venue). If the second one works I'm a little
surprised, as I would have expected:
Forms![frm_Runs]![frm_Points].Form![Run_point_Venue]
(note the bang (exclamation mark) after frmRuns).


efandango said:
yes, the original code works perfectly; and yes, it I am defining a string
in
order that I can parse it to google. Bear in mind I have only posted the
significant line that is giving me problems; specifically with the
replacement version as Tina suggested, using 'Screen.PreviousControl'.

There is nothing wrong with the original code, but clearly there is
something wrong with the synax of the 2nd version, which is what I was
hoping
someone could help me with.



BruceM said:
Does any variant of the code work (specifically, the one you had
originally)? The reason I ask is that it seems you are defining a
string,
but then not doing anything with it. Or are you getting the error just
in
attempting to set the value of stAppName?

If your original code works (despite its limitations), try adding this
line
directly after it:

Debug.Print stAppName

Do the same with the other code (with Screen.PreviousControl).

Switch to the immediate window by pressing Ctrl + G. Compare the
strings.

I have to admit I'm not sure why you are going through the IE executable
file. When I need to go to a hyperlink I use
Application.FollowHyperlink.

Bruce, I will look at the label option, thanks.

regards "what happens when I try"

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


but get error: 'Wrong number of arguments or invalid assignment'

it's the syntax that always foxes me...




:

Then maybe you can use the text box label double click event. To do
this
you need to disassociate the label from the text box, otherwise it
will
not
have double-click event as an option. To disassociate the label,
select
it,
then press Ctrl + X to cut it, and Ctrl + V to paste it. Move it to
where
it needs to be.

Regarding your question "How can I incorporate this", what happens
when
you
try?

unfortunately, that feature option is already taken by another
feature.



:

As a suggestion, try using the double-click event of the specific
text
box
rather than a generic command button.

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


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

tina

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


efandango said:
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


efandango said:
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


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

BruceM

Pertaining to what Tina posted most recently, this is typically the syntax
for referencing an outside form (that is, not the current form or subform):

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

The first "Forms" tells Access it is working with the Forms collection.
"[frm_Runs]" is a form within that collection. "[frm_Points]" references
the subform control (the "box" on the main form that contains the subform)
named "[frmPoints]". Next you are referencing the Form property of the
subform control, which is to say the actual form being used as a subform.
Finally you are referencing the control "[Run_point_Venue]" on the subform.

I expected an exclamation mark (bang) before "[frmPoints]" because a bang
means that what follows is a member of a collection, while a dot means that
what follows is a property. It gets a bit murky, as a control (including a
subform control) is a member of a collection as well as a property, so now
that I think about it you may not need to use the bang, even though it is
typical. I shouldn't have mentioned it.

If your command button is on the main form and you want to reference a
control on the subform you do not need to use the long syntax. Instead you
could use:
Me.frm_Points.Form.Run_point_Venue

Note that brackets are needed only if there is a space or other special
character other than underscore in the name, or if the name is a reserved
word. The same holds true for the long syntax, I believe.

Anyhow, the Me. prefix tells Access that what follows is a property of the
form. With a bang (Me!) what follows is a member of a collection. Again,
controls are both properties and members of a collection (the Controls
collection), so the Me. prefix is fine.

Finally, it could work to use just this:
[Run_point_Venue]
If you are on the subform, and referencing that control or field. It will
not work if you are on the main form and [Run_point_Venue] is on the
subform.

It is not always clear when you are using abbreviated code and when you are
posting actual code.

Your actual complete code line that works is completely different from the
Screen.PreviousControl syntax. In the working code you are combining the
values from several fields. With Screen.PreviousControl you are looking at
a single field. PreviousControl can reference only one control.

When I asked you to add the line:
Debug.Print stAppName
I meant like this:
stAppName = "C:\Program Files\Internet Explorer\iexplore.exe " & _
"http://www.google.co.uk/search?hl=en&q=" & _
Screen.PreviousControl & ",London"
Debug.Print stAppName

The idea of comparing working code with code that does not work is that you
can see where they are different, and fix the non-working code accordingly.
It is not a purely academic exercise. I suspect the problem is that
PreviousControl is not a control with a value. Try this before the lines
above:
Debug.Print Screen.PreviousControl.Name

This will tell you the name of PreviousControl, which may not be what you
expected. If you do not specify a property Access will use the default
property. If the PreviousControl is the subform control or another control
that does not have a Value property, Screen.PreviousControl will fail in a
text string.


efandango said:
When I use the debug option on this line:

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

I just get the same error message box: 'Wrong number of arguments or
invalid
assignment' when I click OK and hit ctrl+G, the intermediate window just
shows rows of digits like this:
-4.118957176925 3104.5170414771 -2463.19426220711



You have posted working code (as I understand it) in two different ways:

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


I don't quite understand this bit?, with regard to the first solo
reference
[Run_point_Venue]

Unless you're referring to my very first post where I did mention that it
is
partial code.

I also, don't know why you would be surprised if this line below does
work,
but I have to say that I am really a novice at this, and don't always
understand why something does or does not work, and tend to rely on trial
and
error:

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


However, this all seems to really digress from the point. Rather than
examine why working code actually works, I was hoping that I could
discover
why non-working code doesn't work.

This is the actual 'complete' code line that works just fine:

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] & ", " &
Forms![frm_Runs].[frm_Points].Form.[Run_point_Address] & ", " & "London, "
&
Forms![frm_Runs].[frm_Points].Form.Run_Point_Postcode

all I did was remove some of the references to make it easier to digest
for
anyone reading it.




BruceM said:
I can only bear in mind what you have posted.

I suggested Debug.Print. What were the results from that? If you
compare
the two strings you can see where the second one (the one that doesn't
work)
differs from the one that does work. If you post the difference I may be
able to suggest a way to get the correct string where that if failing
now.

I did notice that the placement of commas in the "London" part of the
string
are different in the two versions of the code. You have shown:
", " & "London,"
and
",London"

This will yield, respectively:
, London,
and
,London

You have posted working code (as I understand it) in two different ways:

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

Do both of these work? If so, you could just use the first (or better
perhaps, Me.Run_Point_Venue). If the second one works I'm a little
surprised, as I would have expected:
Forms![frm_Runs]![frm_Points].Form![Run_point_Venue]
(note the bang (exclamation mark) after frmRuns).


efandango said:
yes, the original code works perfectly; and yes, it I am defining a
string
in
order that I can parse it to google. Bear in mind I have only posted
the
significant line that is giving me problems; specifically with the
replacement version as Tina suggested, using 'Screen.PreviousControl'.

There is nothing wrong with the original code, but clearly there is
something wrong with the synax of the 2nd version, which is what I was
hoping
someone could help me with.



:

Does any variant of the code work (specifically, the one you had
originally)? The reason I ask is that it seems you are defining a
string,
but then not doing anything with it. Or are you getting the error
just
in
attempting to set the value of stAppName?

If your original code works (despite its limitations), try adding this
line
directly after it:

Debug.Print stAppName

Do the same with the other code (with Screen.PreviousControl).

Switch to the immediate window by pressing Ctrl + G. Compare the
strings.

I have to admit I'm not sure why you are going through the IE
executable
file. When I need to go to a hyperlink I use
Application.FollowHyperlink.

Bruce, I will look at the label option, thanks.

regards "what happens when I try"

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


but get error: 'Wrong number of arguments or invalid assignment'

it's the syntax that always foxes me...




:

Then maybe you can use the text box label double click event. To
do
this
you need to disassociate the label from the text box, otherwise it
will
not
have double-click event as an option. To disassociate the label,
select
it,
then press Ctrl + X to cut it, and Ctrl + V to paste it. Move it
to
where
it needs to be.

Regarding your question "How can I incorporate this", what happens
when
you
try?

unfortunately, that feature option is already taken by another
feature.



:

As a suggestion, try using the double-click event of the
specific
text
box
rather than a generic command button.

message
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


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

efandango

Tina,


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

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

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).

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.



tina said:
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


efandango said:
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


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


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

tina

comments inline.

efandango said:
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 ;)
tina said:
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


efandango said:
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


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


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

efandango

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.


tina said:
comments inline.

efandango said:
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 ;)
tina said:
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


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


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

tina

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


efandango said:
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.


tina said:
comments inline.

efandango said:
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


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


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

efandango

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


efandango said:
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.


tina said:
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


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


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

tina

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


efandango said:
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


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


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

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