Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print a File from VBA

Status
Not open for further replies.

kopy

Technical User
May 30, 2002
141
US
I'm trying to create a Command Button that will print the drawing file associated with the current Part Number. Any help with the VBA for this will be a great help.
Thanks, Kopy
 
kopy, try to speak in more general terms.
What's a "drawing" file?
...a file in same/another directory?

What, where & how, do we find the "Current part Number"?
..from a main/sub form, with the focus?

VBA has many file search and manipulation functions.
And print methods & actions.

Type "file" or "print" in VBA help..
 
How are ya kopy . . .

What you can do is:
[ol][li]Setup a [blue]blank report[/blue] with an [blue]Image Frame[/blue].[/li]
[li]The [blue]On Open[/blue] event of the report sets the [blue]Picture[/blue] property of the image frame via a [blue]global variable[/blue] previously set to the [blue]drawing file[/blue] path & filename.[/li]
[li]To get the ball rolling in the form you could use the [blue]On Dbl Click[/blue] event of the [blue]Part Number[/blue]. The code in the event would look like:
Code:
[blue]   Dim Cri As String
   
   Cri = "[PartNumber] = '" & Me!PartNumber & "'"
   GlobalVariable = DLookup("DrawingFileFieldName", "TableName", Cri)
   DoCmd.OpenReport "ReportName", acViewPreview[/blue]
Be sure to check all the names and the code assumes part number is alphanumeric.[/li][/ol]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see FAQ219-2884:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top