Re: Does a textbox have to have a name reference, or can I use a w
- From: "BruceM" <bamoob_at_yawhodotcalm.not>
- Date: Tue, 5 May 2009 07:55:46 -0400
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" <efandango@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0B471ED2-949C-4320-8E33-15F693F3BD3B@xxxxxxxxxxxxxxxx
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" wrote:
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" <efandango@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:44B7715F-7D29-4A5F-9F1E-7ED66D81B553@xxxxxxxxxxxxxxxx
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" wrote:
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" <efandango@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:62B18434-48C4-4504-8F68-92D57065345A@xxxxxxxxxxxxxxxx
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" wrote:
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" <efandango@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:B7FDAF08-962D-4BB1-BBE2-6E0D3CD2D8E5@xxxxxxxxxxxxxxxx
unfortunately, that feature option is already taken by another
feature.
"BruceM" wrote:
As a suggestion, try using the double-click event of the
specific
text
box
rather than a generic command button.
"efandango" <efandango@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:69A64B6D-F896-4824-BC51-9E5BD66491BF@xxxxxxxxxxxxxxxx
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?
"tina" wrote:
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" <efandango@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:B9BB002E-7DF5-4BB9-B55D-5A1A0911C1F6@xxxxxxxxxxxxxxxx
Ok, I wasn't sure how to title this thread; but here's thedon't
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
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
.
- References:
- Does a textbox have to have a name reference, or can I use a wildc
- From: efandango
- Re: Does a textbox have to have a name reference, or can I use a wildc
- From: tina
- Re: Does a textbox have to have a name reference, or can I use a w
- From: efandango
- Re: Does a textbox have to have a name reference, or can I use a w
- From: BruceM
- Re: Does a textbox have to have a name reference, or can I use a w
- From: efandango
- Re: Does a textbox have to have a name reference, or can I use a w
- From: BruceM
- Re: Does a textbox have to have a name reference, or can I use a w
- From: efandango
- Re: Does a textbox have to have a name reference, or can I use a w
- From: BruceM
- Re: Does a textbox have to have a name reference, or can I use a w
- From: efandango
- Re: Does a textbox have to have a name reference, or can I use a w
- From: BruceM
- Re: Does a textbox have to have a name reference, or can I use a w
- From: efandango
- Does a textbox have to have a name reference, or can I use a wildc
- Prev by Date: Re: Text Box Undo
- Next by Date: placing textfields in a specific place
- Previous by thread: Re: Does a textbox have to have a name reference, or can I use a w
- Next by thread: Re: Does a textbox have to have a name reference, or can I use a w
- Index(es):
Relevant Pages
|