On Click Help

  • Thread starter Thread starter Pam
  • Start date Start date
P

Pam

Hi,

I have posted a couple of times in the DAP group, but have received no help
to question - there is also a lot of ads and testing posts there. I'm
hoping someone here can help. I need a command button set up on the DAP
like in a form where you have an "if" statement to open a pdf file located
on server that matches file name in text box. This is code I use on my
regular search form, but with DAP being HTML I realize it won't work. This
is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
Afraid I can't help you with respect to running that code in a DAP, but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub
 
Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's listed in the
field selected. I would like to know if there is something I should be aware
of.

Thanks again,
Pam


Douglas J. Steele said:
Afraid I can't help you with respect to running that code in a DAP, but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Pam said:
Hi,

I have posted a couple of times in the DAP group, but have received no
help to question - there is also a lot of ads and testing posts there.
I'm hoping someone here can help. I need a command button set up on the
DAP like in a form where you have an "if" statement to open a pdf file
located on server that matches file name in text box. This is code I use
on my regular search form, but with DAP being HTML I realize it won't
work. This is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
Sorry, mental slip on my part. You put Dir, but I read it as Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


PHisaw said:
Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's listed in the
field selected. I would like to know if there is something I should be
aware
of.

Thanks again,
Pam


Douglas J. Steele said:
Afraid I can't help you with respect to running that code in a DAP, but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Pam said:
Hi,

I have posted a couple of times in the DAP group, but have received no
help to question - there is also a lot of ads and testing posts there.
I'm hoping someone here can help. I need a command button set up on
the
DAP like in a form where you have an "if" statement to open a pdf file
located on server that matches file name in text box. This is code I
use
on my regular search form, but with DAP being HTML I realize it won't
work. This is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
Doug,

Thanks for the reply. I know you said you couldn't help with code for the
DAP, but was hoping you wouldn't mind taking a look at some VBScript that
PaulD from the DAP section gave and is giving me a error. I posted back with
the error but have yet to receive a reply. Maybe it is something you could
possibly help me with. I'm using the following code on a command button and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing wrong. Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly appreciate it.
Thanks for your time and help.
Pam

Douglas J. Steele said:
Sorry, mental slip on my part. You put Dir, but I read it as Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


PHisaw said:
Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's listed in the
field selected. I would like to know if there is something I should be
aware
of.

Thanks again,
Pam


Douglas J. Steele said:
Afraid I can't help you with respect to running that code in a DAP, but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but have received no
help to question - there is also a lot of ads and testing posts there.
I'm hoping someone here can help. I need a command button set up on
the
DAP like in a form where you have an "if" statement to open a pdf file
located on server that matches file name in text box. This is code I
use
on my regular search form, but with DAP being HTML I realize it won't
work. This is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
Doug,

Thanks for the reply. I know you said you couldn't help with code for the
DAP, but was hoping you wouldn't mind taking a look at some VBScript that
PaulD from the DAP section gave and is giving me a error. I posted back
with
the error but have yet to receive a reply. Maybe it is something you
could
possibly help me with. I'm using the following code on a command button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly appreciate
it.
Thanks for your time and help.
Pam

Douglas J. Steele said:
Sorry, mental slip on my part. You put Dir, but I read it as Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


PHisaw said:
Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's listed in
the
field selected. I would like to know if there is something I should be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code in a DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but have received
no
help to question - there is also a lot of ads and testing posts
there.
I'm hoping someone here can help. I need a command button set up on
the
DAP like in a form where you have an "if" statement to open a pdf
file
located on server that matches file name in text box. This is code
I
use
on my regular search form, but with DAP being HTML I realize it
won't
work. This is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
That gave me Char: 44
Error: Unterminated string constant

Thanks anyway.
Pam

Douglas J. Steele said:
Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
Doug,

Thanks for the reply. I know you said you couldn't help with code for the
DAP, but was hoping you wouldn't mind taking a look at some VBScript that
PaulD from the DAP section gave and is giving me a error. I posted back
with
the error but have yet to receive a reply. Maybe it is something you
could
possibly help me with. I'm using the following code on a command button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly appreciate
it.
Thanks for your time and help.
Pam

Douglas J. Steele said:
Sorry, mental slip on my part. You put Dir, but I read it as Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's listed in
the
field selected. I would like to know if there is something I should be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code in a DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but have received
no
help to question - there is also a lot of ads and testing posts
there.
I'm hoping someone here can help. I need a command button set up on
the
DAP like in a form where you have an "if" statement to open a pdf
file
located on server that matches file name in text box. This is code
I
use
on my regular search form, but with DAP being HTML I realize it
won't
work. This is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
My typo. There should be four double quotes at the end of the line, not just
three. It's three double quotes in the middle.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
That gave me Char: 44
Error: Unterminated string constant

Thanks anyway.
Pam

Douglas J. Steele said:
Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
Doug,

Thanks for the reply. I know you said you couldn't help with code for
the
DAP, but was hoping you wouldn't mind taking a look at some VBScript
that
PaulD from the DAP section gave and is giving me a error. I posted
back
with
the error but have yet to receive a reply. Maybe it is something you
could
possibly help me with. I'm using the following code on a command
button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly
appreciate
it.
Thanks for your time and help.
Pam

:

Sorry, mental slip on my part. You put Dir, but I read it as Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's listed
in
the
field selected. I would like to know if there is something I should
be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code in a DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but have
received
no
help to question - there is also a lot of ads and testing posts
there.
I'm hoping someone here can help. I need a command button set up
on
the
DAP like in a form where you have an "if" statement to open a pdf
file
located on server that matches file name in text box. This is
code
I
use
on my regular search form, but with DAP being HTML I realize it
won't
work. This is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
I thought so and I tried that and got error msg: Object doesn't support this
property or method: 'ItemNumber1.Value'

Do you have any other suggestions?

Thanks,
Pam

Douglas J. Steele said:
My typo. There should be four double quotes at the end of the line, not just
three. It's three double quotes in the middle.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
That gave me Char: 44
Error: Unterminated string constant

Thanks anyway.
Pam

Douglas J. Steele said:
Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Doug,

Thanks for the reply. I know you said you couldn't help with code for
the
DAP, but was hoping you wouldn't mind taking a look at some VBScript
that
PaulD from the DAP section gave and is giving me a error. I posted
back
with
the error but have yet to receive a reply. Maybe it is something you
could
possibly help me with. I'm using the following code on a command
button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly
appreciate
it.
Thanks for your time and help.
Pam

:

Sorry, mental slip on my part. You put Dir, but I read it as Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's listed
in
the
field selected. I would like to know if there is something I should
be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code in a DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but have
received
no
help to question - there is also a lot of ads and testing posts
there.
I'm hoping someone here can help. I need a command button set up
on
the
DAP like in a form where you have an "if" statement to open a pdf
file
located on server that matches file name in text box. This is
code
I
use
on my regular search form, but with DAP being HTML I realize it
won't
work. This is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
That, I just took from your code. I assumed that it worked!

That could well be the cause of your permission problem: myFile didn't
contain a valid file, so the command failed.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
I thought so and I tried that and got error msg: Object doesn't support
this
property or method: 'ItemNumber1.Value'

Do you have any other suggestions?

Thanks,
Pam

Douglas J. Steele said:
My typo. There should be four double quotes at the end of the line, not
just
three. It's three double quotes in the middle.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
That gave me Char: 44
Error: Unterminated string constant

Thanks anyway.
Pam

:

Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Doug,

Thanks for the reply. I know you said you couldn't help with code
for
the
DAP, but was hoping you wouldn't mind taking a look at some VBScript
that
PaulD from the DAP section gave and is giving me a error. I posted
back
with
the error but have yet to receive a reply. Maybe it is something
you
could
possibly help me with. I'm using the following code on a command
button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly
appreciate
it.
Thanks for your time and help.
Pam

:

Sorry, mental slip on my part. You put Dir, but I read it as Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's
listed
in
the
field selected. I would like to know if there is something I
should
be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code in a
DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but have
received
no
help to question - there is also a lot of ads and testing
posts
there.
I'm hoping someone here can help. I need a command button set
up
on
the
DAP like in a form where you have an "if" statement to open a
pdf
file
located on server that matches file name in text box. This is
code
I
use
on my regular search form, but with DAP being HTML I realize
it
won't
work. This is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
It is a valid file. The field ItemNumber1 in my table is a hyperlink field.
When I click this field, it opens the pdf as I want. If I put this on the
dap it shows the hyperlink address. I do not want the users to see or click
on a hyperlink address to open the pdf. I would prefer the command button
like on a regular access form.

Do you know of any other reasons that my prevent it from working properly?

Thanks again for your time and help.
Pam

Douglas J. Steele said:
That, I just took from your code. I assumed that it worked!

That could well be the cause of your permission problem: myFile didn't
contain a valid file, so the command failed.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
I thought so and I tried that and got error msg: Object doesn't support
this
property or method: 'ItemNumber1.Value'

Do you have any other suggestions?

Thanks,
Pam

Douglas J. Steele said:
My typo. There should be four double quotes at the end of the line, not
just
three. It's three double quotes in the middle.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


That gave me Char: 44
Error: Unterminated string constant

Thanks anyway.
Pam

:

Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Doug,

Thanks for the reply. I know you said you couldn't help with code
for
the
DAP, but was hoping you wouldn't mind taking a look at some VBScript
that
PaulD from the DAP section gave and is giving me a error. I posted
back
with
the error but have yet to receive a reply. Maybe it is something
you
could
possibly help me with. I'm using the following code on a command
button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly
appreciate
it.
Thanks for your time and help.
Pam

:

Sorry, mental slip on my part. You put Dir, but I read it as Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's
listed
in
the
field selected. I would like to know if there is something I
should
be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code in a
DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but have
received
no
help to question - there is also a lot of ads and testing
posts
there.
I'm hoping someone here can help. I need a command button set
up
on
the
DAP like in a form where you have an "if" statement to open a
pdf
file
located on server that matches file name in text box. This is
code
I
use
on my regular search form, but with DAP being HTML I realize
it
won't
work. This is the last step I need to complete search page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
I don't believe you ever mentioned before that it was a hyperlink field in
your table.

Take a look at what's in myFile: you'll find it's more than just the file
name. There are actually three separate parts to a Hyperlink: the displayed
text, the address and the subaddress. At a bare minimum, you're going to
find octothorps (#) before and after the file. You'll have to strip out just
the address from the whole value, and use it.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


PHisaw said:
It is a valid file. The field ItemNumber1 in my table is a hyperlink
field.
When I click this field, it opens the pdf as I want. If I put this on the
dap it shows the hyperlink address. I do not want the users to see or
click
on a hyperlink address to open the pdf. I would prefer the command button
like on a regular access form.

Do you know of any other reasons that my prevent it from working properly?

Thanks again for your time and help.
Pam

Douglas J. Steele said:
That, I just took from your code. I assumed that it worked!

That could well be the cause of your permission problem: myFile didn't
contain a valid file, so the command failed.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
I thought so and I tried that and got error msg: Object doesn't support
this
property or method: 'ItemNumber1.Value'

Do you have any other suggestions?

Thanks,
Pam

:

My typo. There should be four double quotes at the end of the line,
not
just
three. It's three double quotes in the middle.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


That gave me Char: 44
Error: Unterminated string constant

Thanks anyway.
Pam

:

Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Doug,

Thanks for the reply. I know you said you couldn't help with
code
for
the
DAP, but was hoping you wouldn't mind taking a look at some
VBScript
that
PaulD from the DAP section gave and is giving me a error. I
posted
back
with
the error but have yet to receive a reply. Maybe it is something
you
could
possibly help me with. I'm using the following code on a command
button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing
wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly
appreciate
it.
Thanks for your time and help.
Pam

:

Sorry, mental slip on my part. You put Dir, but I read it as
Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's
listed
in
the
field selected. I would like to know if there is something I
should
be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code in
a
DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but have
received
no
help to question - there is also a lot of ads and testing
posts
there.
I'm hoping someone here can help. I need a command button
set
up
on
the
DAP like in a form where you have an "if" statement to open
a
pdf
file
located on server that matches file name in text box. This
is
code
I
use
on my regular search form, but with DAP being HTML I
realize
it
won't
work. This is the last step I need to complete search
page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
Even when I don't use a fieldname.value for myfile and use a pdf located on c
drive, like so: myFile = "C:\bjm.pdf" - it still comes up permission denied.
I also have another field that is not a hyperlink field and has the complete
address to pdf and I used it ItemNumber.Value and same thing.

Thanks, Pam



Douglas J. Steele said:
I don't believe you ever mentioned before that it was a hyperlink field in
your table.

Take a look at what's in myFile: you'll find it's more than just the file
name. There are actually three separate parts to a Hyperlink: the displayed
text, the address and the subaddress. At a bare minimum, you're going to
find octothorps (#) before and after the file. You'll have to strip out just
the address from the whole value, and use it.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


PHisaw said:
It is a valid file. The field ItemNumber1 in my table is a hyperlink
field.
When I click this field, it opens the pdf as I want. If I put this on the
dap it shows the hyperlink address. I do not want the users to see or
click
on a hyperlink address to open the pdf. I would prefer the command button
like on a regular access form.

Do you know of any other reasons that my prevent it from working properly?

Thanks again for your time and help.
Pam

Douglas J. Steele said:
That, I just took from your code. I assumed that it worked!

That could well be the cause of your permission problem: myFile didn't
contain a valid file, so the command failed.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I thought so and I tried that and got error msg: Object doesn't support
this
property or method: 'ItemNumber1.Value'

Do you have any other suggestions?

Thanks,
Pam

:

My typo. There should be four double quotes at the end of the line,
not
just
three. It's three double quotes in the middle.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


That gave me Char: 44
Error: Unterminated string constant

Thanks anyway.
Pam

:

Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Doug,

Thanks for the reply. I know you said you couldn't help with
code
for
the
DAP, but was hoping you wouldn't mind taking a look at some
VBScript
that
PaulD from the DAP section gave and is giving me a error. I
posted
back
with
the error but have yet to receive a reply. Maybe it is something
you
could
possibly help me with. I'm using the following code on a command
button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing
wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly
appreciate
it.
Thanks for your time and help.
Pam

:

Sorry, mental slip on my part. You put Dir, but I read it as
Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Doug,

Thanks for the reply. Will you please explain your comment?
" will never be true, since you're hard-coding parts of it."

I'm using this code in a db form now and it opens the pdf's
listed
in
the
field selected. I would like to know if there is something I
should
be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code in
a
DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but have
received
no
help to question - there is also a lot of ads and testing
posts
there.
I'm hoping someone here can help. I need a command button
set
up
on
the
DAP like in a form where you have an "if" statement to open
a
pdf
file
located on server that matches file name in text box. This
is
code
I
use
on my regular search form, but with DAP being HTML I
realize
it
won't
work. This is the last step I need to complete search
page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
That may well be a limitation on DAPs then, a sandbox mode that prevents the
execution of potentially malicious code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
Even when I don't use a fieldname.value for myfile and use a pdf located
on c
drive, like so: myFile = "C:\bjm.pdf" - it still comes up permission
denied.
I also have another field that is not a hyperlink field and has the
complete
address to pdf and I used it ItemNumber.Value and same thing.

Thanks, Pam



Douglas J. Steele said:
I don't believe you ever mentioned before that it was a hyperlink field
in
your table.

Take a look at what's in myFile: you'll find it's more than just the file
name. There are actually three separate parts to a Hyperlink: the
displayed
text, the address and the subaddress. At a bare minimum, you're going to
find octothorps (#) before and after the file. You'll have to strip out
just
the address from the whole value, and use it.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


PHisaw said:
It is a valid file. The field ItemNumber1 in my table is a hyperlink
field.
When I click this field, it opens the pdf as I want. If I put this on
the
dap it shows the hyperlink address. I do not want the users to see or
click
on a hyperlink address to open the pdf. I would prefer the command
button
like on a regular access form.

Do you know of any other reasons that my prevent it from working
properly?

Thanks again for your time and help.
Pam

:

That, I just took from your code. I assumed that it worked!

That could well be the cause of your permission problem: myFile didn't
contain a valid file, so the command failed.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I thought so and I tried that and got error msg: Object doesn't
support
this
property or method: 'ItemNumber1.Value'

Do you have any other suggestions?

Thanks,
Pam

:

My typo. There should be four double quotes at the end of the line,
not
just
three. It's three double quotes in the middle.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


That gave me Char: 44
Error: Unterminated string constant

Thanks anyway.
Pam

:

Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Doug,

Thanks for the reply. I know you said you couldn't help with
code
for
the
DAP, but was hoping you wouldn't mind taking a look at some
VBScript
that
PaulD from the DAP section gave and is giving me a error. I
posted
back
with
the error but have yet to receive a reply. Maybe it is
something
you
could
possibly help me with. I'm using the following code on a
command
button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing
wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly
appreciate
it.
Thanks for your time and help.
Pam

:

Sorry, mental slip on my part. You put Dir, but I read it as
Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Doug,

Thanks for the reply. Will you please explain your
comment?
" will never be true, since you're hard-coding parts of
it."

I'm using this code in a db form now and it opens the pdf's
listed
in
the
field selected. I would like to know if there is something
I
should
be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code
in
a
DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] &
".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but
have
received
no
help to question - there is also a lot of ads and
testing
posts
there.
I'm hoping someone here can help. I need a command
button
set
up
on
the
DAP like in a form where you have an "if" statement to
open
a
pdf
file
located on server that matches file name in text box.
This
is
code
I
use
on my regular search form, but with DAP being HTML I
realize
it
won't
work. This is the last step I need to complete search
page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
MsgBox "There is no pdf for this brochure."
Else
Application.FollowHyperlink strPath
End If

End Sub
 
I've been searching and have came up with "change html file to hta file" and
supposedly code will work - not mine!! - still have errors and am ready to
throw in the towel!!

Thanks for your time and feedback.
Pam

Douglas J. Steele said:
That may well be a limitation on DAPs then, a sandbox mode that prevents the
execution of potentially malicious code.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


PHisaw said:
Even when I don't use a fieldname.value for myfile and use a pdf located
on c
drive, like so: myFile = "C:\bjm.pdf" - it still comes up permission
denied.
I also have another field that is not a hyperlink field and has the
complete
address to pdf and I used it ItemNumber.Value and same thing.

Thanks, Pam



Douglas J. Steele said:
I don't believe you ever mentioned before that it was a hyperlink field
in
your table.

Take a look at what's in myFile: you'll find it's more than just the file
name. There are actually three separate parts to a Hyperlink: the
displayed
text, the address and the subaddress. At a bare minimum, you're going to
find octothorps (#) before and after the file. You'll have to strip out
just
the address from the whole value, and use it.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


It is a valid file. The field ItemNumber1 in my table is a hyperlink
field.
When I click this field, it opens the pdf as I want. If I put this on
the
dap it shows the hyperlink address. I do not want the users to see or
click
on a hyperlink address to open the pdf. I would prefer the command
button
like on a regular access form.

Do you know of any other reasons that my prevent it from working
properly?

Thanks again for your time and help.
Pam

:

That, I just took from your code. I assumed that it worked!

That could well be the cause of your permission problem: myFile didn't
contain a valid file, so the command failed.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I thought so and I tried that and got error msg: Object doesn't
support
this
property or method: 'ItemNumber1.Value'

Do you have any other suggestions?

Thanks,
Pam

:

My typo. There should be four double quotes at the end of the line,
not
just
three. It's three double quotes in the middle.


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


That gave me Char: 44
Error: Unterminated string constant

Thanks anyway.
Pam

:

Sorry, no idea.

Since you said you're trying to open PDF files, you could try:

dim objShell
dim myFile

set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.Run "acrord32.exe """ & myFile & """
set objShell = Nothing


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Doug,

Thanks for the reply. I know you said you couldn't help with
code
for
the
DAP, but was hoping you wouldn't mind taking a look at some
VBScript
that
PaulD from the DAP section gave and is giving me a error. I
posted
back
with
the error but have yet to receive a reply. Maybe it is
something
you
could
possibly help me with. I'm using the following code on a
command
button
and
am receiving a script error on this line -
objShell.ShellExecute myFile, "", "","open", 1

error is "Permission Denied";
char: 1;
code: 0;
URL: accdp://9017264/


Since I am a newbie, I can't quite figure out what I am doing
wrong.
Here's
the complete code for button.

<SCRIPT language=vbscript event=onclick for=btnPDF>
<!--

dim objShell
dim myFile
set objShell = CreateObject("Shell.Application")
myFile = ItemNumber1.value
objShell.ShellExecute myFile, "", "","open", 1
set objShell = Nothing
-->
</SCRIPT>

If you could point me in the right direction, I would greatly
appreciate
it.
Thanks for your time and help.
Pam

:

Sorry, mental slip on my part. You put Dir, but I read it as
Len.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Doug,

Thanks for the reply. Will you please explain your
comment?
" will never be true, since you're hard-coding parts of
it."

I'm using this code in a db form now and it opens the pdf's
listed
in
the
field selected. I would like to know if there is something
I
should
be
aware
of.

Thanks again,
Pam


:

Afraid I can't help you with respect to running that code
in
a
DAP,
but I
just wanted to point out that it won't work for an MDB.

If Dir(strPath) = "" Then

will never be true, since you're hard-coding parts of it.

You need

Private Sub Command21_Click()
Dim strPath As String

If Len(Me.[ITEM NUMBER] & vbNullString) = 0 Then
MsgBox "There is no pdf for this brochure."
Else
strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] &
".pdf"
Application.FollowHyperlink strPath
End If

End Sub




--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Hi,

I have posted a couple of times in the DAP group, but
have
received
no
help to question - there is also a lot of ads and
testing
posts
there.
I'm hoping someone here can help. I need a command
button
set
up
on
the
DAP like in a form where you have an "if" statement to
open
a
pdf
file
located on server that matches file name in text box.
This
is
code
I
use
on my regular search form, but with DAP being HTML I
realize
it
won't
work. This is the last step I need to complete search
page.

Any help is greatly appreciated.
Pam

Private Sub Command21_Click()
Dim strPath As String

strPath = "\\databases\PDF\" & Me.[ITEM NUMBER] & ".pdf"
If Dir(strPath) = "" Then
 
Back
Top