A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

help with code



 
 
Thread Tools Display Modes
  #11  
Old March 29th, 2007, 12:53 AM posted to microsoft.public.access.tablesdbdesign
Rick Brandt
external usenet poster
 
Posts: 4,354
Default help with code

sue gray wrote:
If I take off the & & strFilespec on the last line I get me path and
filename in the immediate pane. Hope this helps.


I don't understand. strFileSpec is where you had the file name stored. If you
remove that from the Debug.Print line then you should NOT be getting your file
name in the immediate window. You would only get "\\mchdnt\data\mgt\".

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


  #12  
Old March 29th, 2007, 02:04 PM posted to microsoft.public.access.tablesdbdesign
sue gray
external usenet poster
 
Posts: 54
Default help with code

This is what I get in the pane when I take off the & strFilespec

\\mchdnt\data\mgt\Contract_000001.pdf

Thanks again

"Rick Brandt" wrote:

sue gray wrote:
If I take off the & & strFilespec on the last line I get me path and
filename in the immediate pane. Hope this helps.


I don't understand. strFileSpec is where you had the file name stored. If you
remove that from the Debug.Print line then you should NOT be getting your file
name in the immediate window. You would only get "\\mchdnt\data\mgt\".

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com



  #13  
Old March 29th, 2007, 02:28 PM posted to microsoft.public.access.tablesdbdesign
Rick Brandt
external usenet poster
 
Posts: 4,354
Default help with code

sue gray wrote:
This is what I get in the pane when I take off the & strFilespec

\\mchdnt\data\mgt\Contract_000001.pdf


You are either missing something or we are talking past each other. Running
this code (copied from your last post)...

Private Sub Command126_Click()
Dim strFilespec As String
Const CONTRACTS_FOLDER = "\\mchdnt\data\mgt\"
strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"
Debug.Print CONTRACTS_FOLDER & strFilespec
Application.FollowHyperlink CONTRACTS_FOLDER & strFilespec
End Sub

I would expect to see \\mchdnt\data\mgt\Contract_000001.pdf in the immediate
pane. If you remove & strFilespec leaving...

Private Sub Command126_Click()
Dim strFilespec As String
Const CONTRACTS_FOLDER = "\\mchdnt\data\mgt\"
strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"
Debug.Print CONTRACTS_FOLDER
Application.FollowHyperlink CONTRACTS_FOLDER & strFilespec
End Sub

....it is simply NOT possible for you to see
\\mchdnt\data\mgt\Contract_000001.pdf in the immediate window unless you
didn't clear it from a previous run. Did you do that? The immediate pane
doesn't automatically clear itself unless you close and reopen the file or
Access.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


  #14  
Old March 29th, 2007, 03:32 PM posted to microsoft.public.access.tablesdbdesign
sue gray
external usenet poster
 
Posts: 54
Default help with code

I removed & file spec from the application.followhyperlink line of code.

Private Sub Command126_Click()
Dim strFilespec As String
Const CONTRACTS_FOLDER = "\\mchdnt\data\mgt\"
strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"
Debug.Print CONTRACTS_FOLDER & strFilespec
Application.FollowHyperlink CONTRACTS_FOLDER
End Sub

THanks

"Rick Brandt" wrote:

sue gray wrote:
This is what I get in the pane when I take off the & strFilespec

\\mchdnt\data\mgt\Contract_000001.pdf


You are either missing something or we are talking past each other. Running
this code (copied from your last post)...

Private Sub Command126_Click()
Dim strFilespec As String
Const CONTRACTS_FOLDER = "\\mchdnt\data\mgt\"
strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"
Debug.Print CONTRACTS_FOLDER & strFilespec
Application.FollowHyperlink CONTRACTS_FOLDER & strFilespec
End Sub

I would expect to see \\mchdnt\data\mgt\Contract_000001.pdf in the immediate
pane. If you remove & strFilespec leaving...

Private Sub Command126_Click()
Dim strFilespec As String
Const CONTRACTS_FOLDER = "\\mchdnt\data\mgt\"
strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"
Debug.Print CONTRACTS_FOLDER
Application.FollowHyperlink CONTRACTS_FOLDER & strFilespec
End Sub

....it is simply NOT possible for you to see
\\mchdnt\data\mgt\Contract_000001.pdf in the immediate window unless you
didn't clear it from a previous run. Did you do that? The immediate pane
doesn't automatically clear itself unless you close and reopen the file or
Access.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com



  #15  
Old March 29th, 2007, 03:52 PM posted to microsoft.public.access.tablesdbdesign
Rick Brandt
external usenet poster
 
Posts: 4,354
Default help with code

sue gray wrote:
I removed & file spec from the application.followhyperlink line of
code.

Private Sub Command126_Click()
Dim strFilespec As String
Const CONTRACTS_FOLDER = "\\mchdnt\data\mgt\"
strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"
Debug.Print CONTRACTS_FOLDER & strFilespec
Application.FollowHyperlink CONTRACTS_FOLDER
End Sub


A) That should have nothing to do with what you see in the immediate window.

B) That is not going to open a file if all you are doing is pointing at a
folder.

You can also test certain code in the immediate window. In that window (on
a new line) type...

Application.FollowHyperlink "\\mchdnt\data\mgt\Contract_000001.pdf" enter

When you press enter does it work?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com





  #16  
Old March 29th, 2007, 04:06 PM posted to microsoft.public.access.tablesdbdesign
sue gray
external usenet poster
 
Posts: 54
Default help with code

run time error 490, can't open file

"Rick Brandt" wrote:

sue gray wrote:
I removed & file spec from the application.followhyperlink line of
code.

Private Sub Command126_Click()
Dim strFilespec As String
Const CONTRACTS_FOLDER = "\\mchdnt\data\mgt\"
strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"
Debug.Print CONTRACTS_FOLDER & strFilespec
Application.FollowHyperlink CONTRACTS_FOLDER
End Sub


A) That should have nothing to do with what you see in the immediate window.

B) That is not going to open a file if all you are doing is pointing at a
folder.

You can also test certain code in the immediate window. In that window (on
a new line) type...

Application.FollowHyperlink "\\mchdnt\data\mgt\Contract_000001.pdf" enter

When you press enter does it work?

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com






  #17  
Old March 29th, 2007, 04:18 PM posted to microsoft.public.access.tablesdbdesign
Rick Brandt
external usenet poster
 
Posts: 4,354
Default help with code

sue gray wrote:
run time error 490, can't open file


That would suggest that either the file does not exist, the path does not
exist, or you don't have sufficient permissions to the folder and/or file.
When you come up with an expression that DOES work in the immediate window
then you can use that to get your code working.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com


  #18  
Old March 29th, 2007, 04:34 PM posted to microsoft.public.access.tablesdbdesign
sue gray
external usenet poster
 
Posts: 54
Default help with code

I have admin rights and the file is there. I think the problem is in this
line of code:

strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"

I don't even know what it is supposed to do, but what I thought it did was
lfind the document with the 6 digits from the client #. Basically I wanted
to match contract_000123 with client 000123.

If you don't want to keep fighting this with me I understand, you've been
more than generous. Thanks again.

"Rick Brandt" wrote:

sue gray wrote:
run time error 490, can't open file


That would suggest that either the file does not exist, the path does not
exist, or you don't have sufficient permissions to the folder and/or file.
When you come up with an expression that DOES work in the immediate window
then you can use that to get your code working.


--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com



  #19  
Old March 29th, 2007, 06:15 PM posted to microsoft.public.access.tablesdbdesign
Rick Brandt
external usenet poster
 
Posts: 4,354
Default help with code

sue gray wrote:
I have admin rights and the file is there. I think the problem is in
this line of code:

strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"


But when you previously ran the line of code in the immediate window the
line of code above is not in the picture at all and yet you say you still
got an error.

I don't even know what it is supposed to do, but what I thought it
did was lfind the document with the 6 digits from the client #.
Basically I wanted to match contract_000123 with client 000123.


Basically all your code is doing is building a string argument on-the-fly
from two separate pieces and then using those pieces as the argument for
FollowHyperlink.

However; in the immediate window you executed a line of code with a
hard-coded literal value for the FollowHyperlink argument and it didn't
work. Until you get the hard-coded statement to work you can't expect to be
able to dynamically generate that argument string and have it work.

If you don't want to keep fighting this with me I understand, you've
been more than generous. Thanks again.


Simpler (hopefully) example...

Dim FormNamePart1 as String
Dim FormNamePart2 as String

FormNamePart1 = "MyForm"
FormNamePart2 = "Example"
DoCmd.OpenForm FormNamePart1 & FormNamePart2

The last line above is equivelant to...
DoCmd.OpenForm "MyFormExample"

In your case...
DoCmd.OpenForm "MyFormExample"

....produces an error. Given that, it is impossible for...
DoCmd.OpenForm FormNamePart1 & FormNamePart2

....to work. Rather than worrying about why the statement using variables
doesn't work you first have to figure out why the statement that does NOT
use variables doesn't work. Until you have that figured out the rest makes
no difference.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com




  #20  
Old March 29th, 2007, 06:26 PM posted to microsoft.public.access.tablesdbdesign
sue gray
external usenet poster
 
Posts: 54
Default help with code

Ok, I will work from that angle. Thanks again for all your help. I really
appreciate your time and talent.

Sue

"Rick Brandt" wrote:

sue gray wrote:
I have admin rights and the file is there. I think the problem is in
this line of code:

strFilespec = "Contract_" & Format(Me.clientid, "000000") & ".pdf"


But when you previously ran the line of code in the immediate window the
line of code above is not in the picture at all and yet you say you still
got an error.

I don't even know what it is supposed to do, but what I thought it
did was lfind the document with the 6 digits from the client #.
Basically I wanted to match contract_000123 with client 000123.


Basically all your code is doing is building a string argument on-the-fly
from two separate pieces and then using those pieces as the argument for
FollowHyperlink.

However; in the immediate window you executed a line of code with a
hard-coded literal value for the FollowHyperlink argument and it didn't
work. Until you get the hard-coded statement to work you can't expect to be
able to dynamically generate that argument string and have it work.

If you don't want to keep fighting this with me I understand, you've
been more than generous. Thanks again.


Simpler (hopefully) example...

Dim FormNamePart1 as String
Dim FormNamePart2 as String

FormNamePart1 = "MyForm"
FormNamePart2 = "Example"
DoCmd.OpenForm FormNamePart1 & FormNamePart2

The last line above is equivelant to...
DoCmd.OpenForm "MyFormExample"

In your case...
DoCmd.OpenForm "MyFormExample"

....produces an error. Given that, it is impossible for...
DoCmd.OpenForm FormNamePart1 & FormNamePart2

....to work. Rather than worrying about why the statement using variables
doesn't work you first have to figure out why the statement that does NOT
use variables doesn't work. Until you have that figured out the rest makes
no difference.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com





 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.