Do you know what line of code is causing this error?
Okay, currently my error message is "Invaild use of null", I'm not sure
what
I did to change that. My On Click Event Procedure is:
Private Sub Archive_Button_Click()
Dim linksource As String
Dim linkdestination As String
linksource = ExtractAddressFromHyperlink(Me.Report)
linkdestination = "\\Qc_pdc\pptd\Log\Reports\FY Reports 2006" &
[ReferenceNo] & ".zip" '1
FileCopy linksource, linkdestination
End Sub
The On Click field is indeed set to [Event Procedure]
Thanks again for your help!
:
Let me just make sure we're talking about the same thing:
When you say you modified the On_Click properties, do you mean that you
changed the code which runs when you click the button?
(We usually call that the button's OnClick Event Procedure.)
Could you post the full code for that procedure, as it stands now?
Also, open the form in Design View, select the button, and verify in its
Properties Page that OnClick is set to [Event Procedure].
Thanks! I put the function you sent me in a module and modified the
On_Click
properties, however when I press the button nothing happens. Am I
missing
(yet another) step?
:
Well, I'd guess that the address you want to extract is this:
\\Qc_pdc\pptd\Log\Reports\mhuddleston\MMP testing\1226\2614-05.zip
You could write a little function like this:
Public function ExtractAddressFromHyperlink(HLink as String) as
String
Dim HashPlace as long
HashPlace=Instr(HLink,"#")
ExtractAddressFromHyperlink=left(HLink,HashPlace-1)
End Function
Then you can set your linksource like this:
linksource = ExtractAddressFromHyperlink(Me.Report)
HTH
Well, Me.Report is a text box bound to a field in a master table
which
stores
a hyperlink. When I did the msgbox Me.Report I got:
\\Qc_pdc\pptd\Log\Reports\mhuddleston\MMP
testing\1226\2614-05.zip#\\Qc_pdc\pptd\Log\Reports\mhuddleston\MMP
testing\1226\2614-05.zip#
So I'm not sure what to do next.
:
What is Me.Report?
Is it a textbox, which holds the full path/filename to a file
you
want
to
move?
If not, it doesn't seem surprising that Access can't find the
file
you
say
you want to move.
Is it perhaps in hyperlink form?
In that case, you'll probably need to parse out the
information
you
need.
I'd suggest putting
msgbox Me.Report
just before your FileCopy statement - that will show you
what
Access
sees in that control. If it's not obvious to you how to parse
out
the
full
path/filename, post the contents of the messagebox, and we'll
try to
help...
message
I guess I don't see how creating that message box for a
particular
file
will
help me create code that can apply to a wide range of files.
Here is what I have so far:
Dim linksource As String
Dim linkdestination As String
linksource = "Me.Report" '
linkdestination = "\\Qc_pdc\pptd\Log\Reports\FY
Reports
2006"
&
[ReferenceNo] & ".zip" '1
FileCopy linksource, linkdestination
I get a file not found error. Can you help? I'm starting to
reach
the
point of desperation. I can't find anyone who seems to know
exactly
how
to
do it, and I am not well versed in code.
:
If your only problem is how to refer to a file name when it
is
displayed
in
a control on a form (data is stored in fields in tables,
displayed
in
controls on forms), that's not too difficult.
Any data-bound control in Access has a .Value property,
which
returns
the value it represents.
So, if your hyperlink is displayed in a textbox named
HLink,
you
could
do this:
In the OnClick procedure of your button, type
something
like
this:
MsgBox HLink.Value
Now, when you click on the button, you should get a
little
gray
box
giving you the value of that textbox. I think hyperlinks
are
stored
with
the value to display, a # sign, and the target of the
hyperlink,
but
this
will show you exactly what the syntax is.
You should then be able to figure out how to parse this to
get
the
value
you
need.
HTH
message
I don't think the real details are necessary, but here are
the
basics.
I
have a single form with a single hyperlink with a
reference
number
as
its
primary key. This hyperlink is to a compressed (.zip)
file
stored
on
our
lab
server. At the discretion of our boss certain
hyperlinked
files
need to
be
saved in another folder on this server. I would think
that
a
command
button could copy the hyperlinked file from one location
and
save
it
to
another. I have looked at the FileCopy function, but I
can
find
no
reference
on how refer to a file name when it is stored as a field
on a
form.
Not
to
mention I'm still a little unsure how to set up the
destination
file
(though
I may have figured it out). I hope that helps.
:
OK, I guess I don't really get the picture of what you
a. are doing
b. want to be able to do
Can you tell me a little more about these hyperlinks?
Is there a single hyperlink on the form, or does
each
record
have
its
own hyperlink.
Where are the files now?
Where do you want the files to go?
How do you conceive of determining which files are
moved?
"MichelleNH" <
[email protected]>
wrote in
message
I probably should have clarified this, but I have
looked
at
previously
submitted suggestions (including the FileCopy