Print Table data in VBA

Sorrells

Registered User.
Local time
Today, 18:41
Joined
Jan 13, 2001
Messages
258
I know this should be obvious, but it is evading me. I have 33 tables that I built in a form via sql statements. Now I want to print the tables exactly as they would look in View Mode in the VBA code.

I cannot find the command or commands to do this. This is for admin purposes and I do not want to create reports for this.

Any help would be appreciated!
 
This is about as good as I can come up with...

Code:
Private Sub Command7_Click()
Dim i As Integer
Dim tdf As TableDefs
Set tdf = CurrentDb.TableDefs
For i = 0 To tdf.Count - 1
If Left(tdf(i).Name, 4) <> "MSys" Then 'prevent system tables from printing (prefixed with MSys)
                                        
      
        DoCmd.OpenTable tdf(i).Name
        DoCmd.PrintOut acPrintAll, , , acDraft, 1, True
        DoCmd.Close

End If
Next i
Set tdf = Nothing

End Sub

Unfortuntunately I can't suppress the 'printer is printing' dialog box but hey, this is free :)
 
Having reread your question I may be off on another tangent. The above will print every table in the database except system tables. If you require something different, ask again. Can you explain what you mean by 'I have tables built in forms'
 
Fornatian,

Thanks for your reply.

"I have 33 tables that I built in a form via SQL statements." is a little ambiguous! I populated 30 (actually) tables. And I did find the print statement, not in Help or a forum but with the Command Button Wizard under the misc. option, I believe.

It uses the Printout statement. Of course, as soon as I saw the code, I was on a run. It looks like this:

Dim stDocName As String
Dim MyForm As Form

stDocName = "Available_Tasks"
Set MyForm = Screen.ActiveForm
DoCmd.SelectObject acTable, stDocName, True
DoCmd.PrintOut
DoCmd.SelectObject acForm, MyForm.name, False

and will print the table Available_Tasks.
 

Users who are viewing this thread

Back
Top Bottom