RichardPrewitt
IS-IT--Management
I have a program that has a couple problems that have to be fixed yesterday.
I need to get the program to do a print preview or page setup (be able to specify which pages they want to print, like pages 23-31 of 45 or page 27 of 45) Can anyone help me with code that does this without giving them access to the whole database.
The code that i am using currently is:
If txtSpot.Text = "" Then
Else
'Set index property required for seek
datMachine.Recordset.Index = "spotnumber"
'Seek a record in the task table to see if the spot number exists
datMachine.Recordset.Seek "=", txtSpot.Text
If datMachine.Recordset.NoMatch = True Then
MsgBox "Please enter a valid machine spot number"
txtSpot.SetFocus
Save = False
Action = vbDataActionCancel
Exit Sub
End If
lblspot.Caption = txtSpot.Text
datDate.Recordset.Edit
datDate.Recordset.Update
End If
If Timer1.Tag = "" Then
Timer1.Tag = "4"
Timer1.Enabled = True
Exit Sub
End If
'Prints the Task Report from Access to the users default printer
Dim objAccAppl As Access.Application
On Error GoTo ErrorHandler
If txtSpot.Text = "" Then
Set objAccAppl = GetObject("C:\dp283\dp283.mdb")
objAccAppl.DoCmd.OpenReport "task", acViewNormal
Else
Set objAccAppl = GetObject("C:\dp283\dp283.mdb")
objAccAppl.DoCmd.OpenReport "task2", acViewNormal
End If
Timer1.Tag = ""
Exit Sub
ErrorHandler:
MsgBox "Please make sure that the printer is on, has paper and is not currently in use"
I can do a print preview with this code:
'added changes to test for print preview
'***************************************
'Set objAccAppl = GetObject("C:\dp283\dp283.mdb")
'objAccAppl.DoCmd.OpenReport "task", acViewPreview
'objAccAppl.Visible = True
'
'If vbOK = MsgBox("Continue with print?", vbOKCancel) Then
'Else
' Unload Me
' End
'End If
'
'objAccAppl.DoCmd.OpenReport "task", acViewNormal
'
'objAccAppl.Quit acQuitSaveNone
'Set objAccAppl = Nothing
'***************************************
'end of changes
but it lets you do a print preview in Access of the report that is selected. But this also lets them roam free in the database. The can close the selected report or hit design view or any other things that you can do if you just double clicked on the actual database. I only want them to be able to see the report and then pick a page or range of pages to print from.
Another problem that I am having is:
The problem is that when it prints, it first prints the report very about 3 inches by 2 inches in the top left corner. It is the full page and everything is correct but it just prints the whole page really small in that corner. On the second try of printing the report it prints fine. Is there any fix for this?
PS
I was told that this problem is supposed to be in a printer forum? I cannot find a forum dedicated to periphals or printers, so I am posting here. If you know where I am to move this thread please e-mail me or pm me.
Thanks for all of your help,
Richard
I need to get the program to do a print preview or page setup (be able to specify which pages they want to print, like pages 23-31 of 45 or page 27 of 45) Can anyone help me with code that does this without giving them access to the whole database.
The code that i am using currently is:
If txtSpot.Text = "" Then
Else
'Set index property required for seek
datMachine.Recordset.Index = "spotnumber"
'Seek a record in the task table to see if the spot number exists
datMachine.Recordset.Seek "=", txtSpot.Text
If datMachine.Recordset.NoMatch = True Then
MsgBox "Please enter a valid machine spot number"
txtSpot.SetFocus
Save = False
Action = vbDataActionCancel
Exit Sub
End If
lblspot.Caption = txtSpot.Text
datDate.Recordset.Edit
datDate.Recordset.Update
End If
If Timer1.Tag = "" Then
Timer1.Tag = "4"
Timer1.Enabled = True
Exit Sub
End If
'Prints the Task Report from Access to the users default printer
Dim objAccAppl As Access.Application
On Error GoTo ErrorHandler
If txtSpot.Text = "" Then
Set objAccAppl = GetObject("C:\dp283\dp283.mdb")
objAccAppl.DoCmd.OpenReport "task", acViewNormal
Else
Set objAccAppl = GetObject("C:\dp283\dp283.mdb")
objAccAppl.DoCmd.OpenReport "task2", acViewNormal
End If
Timer1.Tag = ""
Exit Sub
ErrorHandler:
MsgBox "Please make sure that the printer is on, has paper and is not currently in use"
I can do a print preview with this code:
'added changes to test for print preview
'***************************************
'Set objAccAppl = GetObject("C:\dp283\dp283.mdb")
'objAccAppl.DoCmd.OpenReport "task", acViewPreview
'objAccAppl.Visible = True
'
'If vbOK = MsgBox("Continue with print?", vbOKCancel) Then
'Else
' Unload Me
' End
'End If
'
'objAccAppl.DoCmd.OpenReport "task", acViewNormal
'
'objAccAppl.Quit acQuitSaveNone
'Set objAccAppl = Nothing
'***************************************
'end of changes
but it lets you do a print preview in Access of the report that is selected. But this also lets them roam free in the database. The can close the selected report or hit design view or any other things that you can do if you just double clicked on the actual database. I only want them to be able to see the report and then pick a page or range of pages to print from.
Another problem that I am having is:
The problem is that when it prints, it first prints the report very about 3 inches by 2 inches in the top left corner. It is the full page and everything is correct but it just prints the whole page really small in that corner. On the second try of printing the report it prints fine. Is there any fix for this?
PS
I was told that this problem is supposed to be in a printer forum? I cannot find a forum dedicated to periphals or printers, so I am posting here. If you know where I am to move this thread please e-mail me or pm me.
Thanks for all of your help,
Richard