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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Program Problem needs Fixed Fast!! Please Help!

Status
Not open for further replies.

RichardPrewitt

IS-IT--Management
Apr 16, 2002
57
0
0
US
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
 
Um wow, that's going to be some work ;) Thanks for the added help, now back to the pilot part of the project ;)

THANKS AGAIN!

I wonder if this will also fix my problem with the printing being too small on the first print command?

Anyways

Thanks,

Richard
 
I have been messing around with the code that they provide on the link above, but they do not mention anything as to how to set up the pages property:

VBPrinterConstants.cdlPDPageNums

I added that line above in the VBPrinterConstant section.
I know that this is the VBPrinterConstant that I need to set the flags for the PrinterDlg object but what code do I use once I've established a flag? I have no experience in printer controls so any examples would be great! The code that I used is also in the example in the link. I modified it a little to disable the print to file and a few other things, but there's no example as to allow the user is to specify a range of pages to print.

Example:

In the link above they have the following code to retrieve the choices from the user and apply them to the printer settings for landscape or portrait:

Printer.Orientation = printDlg.Orientation


Debug.Print .DeviceName
If .Orientation = 1 Then
strsetting = "Portrait. "
Else
strsetting = "Landscape. "
End If
Debug.Print "Copies = " & .Copies, "Orientation = " & _
strsetting


So what do I do for page range?

I know that

printDlg.Flags = VBPrinterConstants.cdlPDPageNums

is the VBPrinterConstant flag for the PrinterDlg but I have no idea as to what to put for catching the choices from the user and applying them like the above code or landscape and portrait.

Thanks for the help,
Richard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top