Thank you Ken. What you suggested is my usual technique...to set the
ControlSource of a textbox to an expression or value, making the
textbox
invisible on the switchboard form, which I know is always open. Can you
tell
me how I can set the textbox's default value to %appdata%\tempfile?
:
In a form, all fields in the RecordSource are referenced only through
the
dot notation because the fields are seen as part of the form's
Properties
collection.
All controls can be referenced through either the bang or dot notation
because ACCESS automatically adds each control to the form's
Properties
collection. When you have a field and control named the same, the use
of
the
dot notation can cause confusion as to which object (field or control)
is
to
be referenced.
You could use either a field or unbound textbox for the default path.
If
the
former, you could use the field's DefaultValue to assign the path. If
the
latter, I'd set the ControlSource of the textbox to an expression that
gives
you the default path, and I'd make the textbox invisible on the form.
--
Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
Bingo! Thanks for staying with me.
How do you know when to use ].[ instead of ]![ ?
Now that I've put us through all that, I started thinking of
workarounds
in
the interim. It occurs to me that I'd be safer to assign the
%appdata%
path
to this field, followed by \tempfile. Yes, this field is, as you
guessed,
a
field in the form's RecordSource. But maybe it doesn't have to be.
It
could
be unbound and have the default value of %appdata%\tempfile.
:
Then that suggests to me that [Forms]![aa]![wsLogin] is not a valid
reference to the form's control where you have stored the user
name.
By
chance, is wsLogin a field in the form's RecordSource? If yes, try
[Forms]![aa].[wsLogin] as the reference.
--
Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
Thank you Ken. I did try that before even bothering you. I get:
c:\documents and settings\Error 0\application
data\tempfile\merge.txt
is
not
a valid path.
:
Try this, then:
="c:\documents and settings\" & CStr([Forms]![aa]![wsLogin]) &
"application
data\tempfile\merge.txt"
--
Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
message
Thanks Ken. Yes the form is open. The wsLogin name is Kathy.
Never
any
special characters. However, I do notice that when I put that
field
in
a
query, it shows up right justified for some reason. When I
transfer
that
field to msWord for other purposes, I have to put a
CStr(format([wsLogin])
to
have the field transfer over and be understood by msWord.
:
Show examples of user login names... any special characters
in
them?
And
perhaps obvious issue: is the form open when the macro runs?
--
Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
message
Hi Ken,
I'm in a similar, yet simpler situation. I want to tell
Access
to
TransferDatabase to the %appdata% \tempfile folder. So
after
reading
your
advice, I tried this in the Filename argument:
="c:\documents and settings\" & [Forms]![aa]![wsLogin] &
"application
data\tempfile\merge.txt"
I'm getting a Type Mismatch error when I run the macro.
The
forms!aa!wsLogin field contains the user's login name.
I'd appreciate any help you can give.
TIA,
Kathy
:
If the "parameter" value is found in a textbox or combobox
or
listbox
on
a
form that is open when the macro runs:
="C:\Documents and Settings\Administrator\My
Documents\TPA\"
&
Forms!NameOfForm!NameOfControl.Value & "\NEW\" &
Forms!NameOfForm!NameOfControl.Value & ".xlsx"
Note that you must use the = and " characters in the
expression
for
the
path
argument.
--
Ken Snell
<MS ACCESS MVP>
http://www.accessmvp.com/KDSnell/
I have a Access macro containing a Tranferspreadsheet
step.
How
do I
use a
parameter for the folder name and file name. Example:
C:\Documents and Settings\Administrator\My
Documents\TPA\parameter\NEW\parameter.xlsx
Thank you.