|
-
Sep 6th, 2000, 07:02 AM
#1
Thread Starter
Junior Member
printing from VB within Access '97
I know that the following code will print data to a file. How can I have the same data sent directly to a printer?
---------------------------------------------------
Private Sub Command3_Click()
Dim intCount As Integer, strCount As String
Open "TESTFILE" For Output As #1
intCount = 1
Do While intCount < 11
Print #1, "This is line "; strCount
intCount = intCount + 1
Loop
Close #1
End Sub
---------------------------------------------------
Any assistance would be appreciated.
-
Sep 6th, 2000, 07:07 AM
#2
Fanatic Member
In a very similar way.
Code:
Dim intCount As Integer, strCount As String
intCount = 1
Do While intCount < 11
Printer.Print "This is line "; strCount
intCount = intCount + 1
Loop
'tells the page to be sent
Printer.EndDoc
'or this may work
Shell "copy TESTFILE Lpt1"
Iain, thats with an i by the way!
-
Sep 6th, 2000, 07:23 AM
#3
Thread Starter
Junior Member
lain,
When I tried using Printer.print I received a Compile error: Variable not defined. It then hi-lited the Printer portion of Printer.print. How do I define the Printer?
-
Sep 6th, 2000, 07:50 AM
#4
Fanatic Member
The Printer object of VB is a global object. Like the Screen object or the App object.
There is no need to define it. I am not really sure what is wrong, it should compile, even if you do not actually have a printer installed.
Sorry to insult you by asking, but you did spell it right didn't you? Other than that, what version of VB do you have?
Iain, thats with an i by the way!
-
Sep 6th, 2000, 08:07 AM
#5
Thread Starter
Junior Member
iain,
No insult taken. I'm prone to mistakes like anyone else. However, I did spell it correctly. I did, however, fail to mention that I was using VB through Microsoft Access '97. Don't know if that makes a difference or not.
ern
-
Sep 6th, 2000, 10:02 AM
#6
Fanatic Member
Well that is the problem then.
I dont have access up and running, so i cant really help much. I had a quick look in word, which i think has simialr objects, and there was no printer object.
What i have managed to gather is there is a
Report.Print Method
and a
DoCmd.PrintOut Method
Try looking at those. Otherwise, maybe someone else can help. Sorry i couldnt help more.
Iain, thats with an i by the way!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|