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