error message 2465

S

stan

This code is attached to a button to retrieve documents stored in one
location-then moved to another. I'm a little puzzled by a message I get when
I hit the "cancel" button on the form (the rest of it seems t work OK). I
get:

"Microsoft Office Access can't find the field "|" referred to in your
expression (2465)"

This is the code:

Private Sub Command16_Click()
On Error GoTo err_cmdFetchAndStore_Click
Dim strStartSearch As String
Dim strOutgoingDirectory As String
Dim strFilter As String

strOutgoingDirectory = DLookup("FilePath", "Common", "[ID]=1")

strStartSearch = "C:\program files"
strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.PDF)", "* .PDF")


Dim strInputFileName As String
Dim strSQL As String
Dim strFileName As String

DoCmd.RunCommand acCmdSaveRecord


strInputFileName = ahtCommonFileOpenSave( _
OpenFile:=True, _
DialogTitle:="Please select an input file...", _
InitialDir:=strStartSearch, _
Flags:=ahtOFN_HIDEREADONLY)
strFileName = Me.[exp].Value & "-" & "[exp].pdf"
FileCopy strInputFileName, strOutgoingDirectory & "\" & strFileName
strSQL = "Update Requisition Set [exp] = '" & strOutgoingDirectory &
"\" & strFileName & "' where Requisition = " & Me.[exp]
DoCmd.SetWarnings False

DoCmd.RunSQL strSQL

exit_cmdFetchAndStore_Click:
DoCmd.SetWarnings True

Exit Sub
err_cmdFetchAndStore_Click:
MsgBox Err.Description & " (" & Err.Number & ")"
Resume exit_cmdFetchAndStore_Click
End Sub
 
A

Allen Browne

If you cancel the file dialog, it returns a zero-length string.

Modify you code to test for that, e.g.:
If strFilter <> "" Then
'put the rest of the code in here
Else
MsgBox "okay: nothing doing"
End If
 
S

stan

Thanks so much Allen, but I still can't shake that message. Where in the
code would you put the modification?
--
stan


Allen Browne said:
If you cancel the file dialog, it returns a zero-length string.

Modify you code to test for that, e.g.:
If strFilter <> "" Then
'put the rest of the code in here
Else
MsgBox "okay: nothing doing"
End If

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.


stan said:
This code is attached to a button to retrieve documents stored in one
location-then moved to another. I'm a little puzzled by a message I get
when
I hit the "cancel" button on the form (the rest of it seems t work OK). I
get:

"Microsoft Office Access can't find the field "|" referred to in your
expression (2465)"

This is the code:

Private Sub Command16_Click()
On Error GoTo err_cmdFetchAndStore_Click
Dim strStartSearch As String
Dim strOutgoingDirectory As String
Dim strFilter As String

strOutgoingDirectory = DLookup("FilePath", "Common", "[ID]=1")

strStartSearch = "C:\program files"
strFilter = ahtAddFilterItem(strFilter, "PDF Files (*.PDF)", "*
.PDF")


Dim strInputFileName As String
Dim strSQL As String
Dim strFileName As String

DoCmd.RunCommand acCmdSaveRecord


strInputFileName = ahtCommonFileOpenSave( _
OpenFile:=True, _
DialogTitle:="Please select an input file...", _
InitialDir:=strStartSearch, _
Flags:=ahtOFN_HIDEREADONLY)
strFileName = Me.[exp].Value & "-" & "[exp].pdf"
FileCopy strInputFileName, strOutgoingDirectory & "\" & strFileName
strSQL = "Update Requisition Set [exp] = '" & strOutgoingDirectory &
"\" & strFileName & "' where Requisition = " & Me.[exp]
DoCmd.SetWarnings False

DoCmd.RunSQL strSQL

exit_cmdFetchAndStore_Click:
DoCmd.SetWarnings True

Exit Sub
err_cmdFetchAndStore_Click:
MsgBox Err.Description & " (" & Err.Number & ")"
Resume exit_cmdFetchAndStore_Click
End Sub

.
 
J

John Spencer

You need to check right after you make the call ahtFileOpenSave.

If Len(strInputFileName) = 0 THEN Exit Sub

OR


If Len(strInputFileName) = 0 Then GOTO exit_cmdFetchAndStore_Click

OR


If Len(strInputFileName) <> 0 THEN
'Your code

End IF
exit_cmdFetchAndStore_Click:




John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
 
S

stan

works perfectly-Thanks!
--
stan


John Spencer said:
You need to check right after you make the call ahtFileOpenSave.

If Len(strInputFileName) = 0 THEN Exit Sub

OR


If Len(strInputFileName) = 0 Then GOTO exit_cmdFetchAndStore_Click

OR


If Len(strInputFileName) <> 0 THEN
'Your code

End IF
exit_cmdFetchAndStore_Click:




John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

.
 
T

tom_willpa

high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD
hairstraightener supplier from www.willpa.com

Are you a Retail businessman who bother by the purchase price? China
Cheapest TOP wholesale website can help you

we are specialize in replica sport goods manufacturing in china, we can
offer you all kinds of soccer jersey, NBA jersey,shoes and so on. they are
the best brand replica goods whih are look the same as the original goods.
excellent quality and steady supply for them. we have been marketed in Europe
and American for 3 year. all the goods we offer are AAA quality. our soccer
jersey are Thailand style. If any goods you buy from my company have problem,
we will refund or resend them again. Most of ourProducts have no minimum
order requirements,soyou can shop retail goods at wholesale prices. if you
can buy more than 300usd. We offer free shipping. The more you buy the more
discount for you.

National soccer jerseys: http://www.willpa.com
Club soccer jerseys: http://www.willpa.com
NBA Jerseys: http://www.willpa.com
T-shirt and shirt: http://www.willpa.com
Tracksuit: http://www.willpa.com
Hoody & Jackets: http://www.willpa.com
UGG boots: http://www.willpa.com
Hair style: http://www.willpa.com
shopping Index: http://www.willpa.com

EMS shipping. 7days arrive, paypal accept

want more information pls contact us or check our website: www.willpa.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top