Connecting Tech Pros Worldwide Forums | Help | Site Map

Print a file in a database

Brian Turner
Guest
 
Posts: n/a
#1: Nov 13 '05
I have a filenane defined in a table in my database. This filename
field is also displayed on my form. I have place a print button on my
form. I would like to be abel to click the Print button on the form
and print out the file defined in the filename field. How can I do
this?

I thought of using a DOS command on the Print button but not sure what
that command is. Thanks in advance.

MGFoster
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Print a file in a database


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Easy, old-style way using the Shell() function:

dim strCmd as string, strSource as string, strTarget as string

' Path to the source file
strSource = "C:\My Documents\myFile.txt"

' Set the target as the printer
strTarget = "PRN:"

' The DOS command to redirect the display of the source file
' to the printer device.
strCmd = "type " & strSource & " > " & strTarget

' Use the Shell function to carry out the DOS command
Shell strcmd, vbHide

Problems: If an error occurs you won't know it.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQRPXSYechKqOuFEgEQLf9wCggQK0hpcL3vgpVcsesSIKRE EWWwEAoPYg
AwAyqqRxU5R6Hk5GV3xnw67y
=5Gys
-----END PGP SIGNATURE-----


Brian Turner wrote:
[color=blue]
> I have a filenane defined in a table in my database. This filename
> field is also displayed on my form. I have place a print button on my
> form. I would like to be abel to click the Print button on the form
> and print out the file defined in the filename field. How can I do
> this?
>
> I thought of using a DOS command on the Print button but not sure what
> that command is. Thanks in advance.[/color]

Closed Thread