Kevin -
Those results imply that fPrintFile is encountering an error, but you aren't
printing out the error message. Temporarily change this line:
to this:
Debug.Print fPrintFile(rs("fldname"))
Then run the function and look in the Immediate Window to see what the
function returns as an error message.
By the way, Is "fldname" really the name of the field in your table that
contains the file paths to print? If not, change that to the correct field
name.
--
Dirk Goldgar, MS Access MVP
Access tips:
www.datagnostics.com/tips.html
(please reply to the newsgroup)
ok thanks for reply getting there
i have modified the module as you suggested
the code is looping 3 times (number of files)
but not printing
so here we go
the recordset result is
C:\TEMP\Test.doc
C:\TEMP\Test 1.doc
C:\TEMP\Test 2.doc
the code under the command button is
Private Sub Command9_Click()
On Error GoTo err_Command9_Click
Dim rs As Recordset
Dim DB As Database
Set rs = CurrentDb.OpenRecordset("tbl_emailsBase")
MsgBox "!" ' testing the code gets here
While Not rs.EOF
MsgBox "7" ' testing the code gets here
fPrintFile rs("fldname")
DoEvents: DoEvents: DoEvents
rs.MoveNext
Wend
MsgBox "3" ' testing the code gets here
Exit_Command9_Click:
Exit Sub
err_Command9_Click:
MsgBox Err.Description
Resume Exit_Command9_Click
End Sub
So i know the code looped through the code
the module is as follows
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&
'===================================== start of code
==========================
Function fPrintFile(stFile As String) ' This function uses
ShellExecute to print, rather than open, the file.
Dim lRet As Long, varTaskID As Variant
Dim stRet As String
lRet = apiShellExecute(hWndAccessApp, "print", stFile,
vbNullString, vbNullString, 0&)
MsgBox "Fprint 1" ' testing code
If lRet > ERROR_SUCCESS Then
MsgBox "Fprint 1.1" ' testing code
stRet = vbNullString
lRet = -1
MsgBox "Fprint 10" ' testing code
Else
Select Case lRet
Case ERROR_NO_ASSOC:
stRet = "Error: No associated application. Couldn't
print!"
Case ERROR_OUT_OF_MEM:
stRet = "Error: Out of Memory/Resources. Couldn't
print!"
Case ERROR_FILE_NOT_FOUND:
stRet = "Error: File not found. Couldn't print!"
Case ERROR_PATH_NOT_FOUND:
stRet = "Error: Path not found. Couldn't print!"
Case ERROR_BAD_FORMAT:
stRet = "Error: Bad File Format. Couldn't print!"
Case Else:
End Select
MsgBox "Fprint 11" ' testing code
End If
fPrintFile = lRet & IIf(stRet = "", vbNullString, ", " & stRet)
MsgBox "Fprint 2" ' testing code
End Function
'===================================== end of code
==========================
when i run the message sequence is
!
7
fprint 1
fprint 11
fprint 2
7
fprint 1
fprint 11
fprint 2
7
fprint 1
fprint 11
fprint 2
3
any ideas where i going wrong on this
thanks again
kevin