|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Print Access Report - VB6
I've got an report in an access2k db that i'm trying to print from a vb6 from end. I want to filter the report down to print a single record, which is identified by the ID Field (autonumber).
here is my code.. Private Sub cmdprintticket_Click() Dim acApp As Access.Application Dim StrSQL As String StrSQL = "[ID]=" & Me.Text2.Text Set acApp = New Access.Application acApp.OpenCurrentDatabase "Z:\Front End\AeCorpR3.mdb" acApp.DoCmd.OpenReport "Service_Call", acViewPreview, , StrSQL acApp.DoCmd.Printout acApp.Quit Set acApp = Nothing End Sub I've tried using the variable NewRecordID as well as making the autonumber show in a text box (text2) but it prints the report, just not the record i'm specifying... it prints another record.... What in the world? Please let me know what it's doing. I'm using ADO and an access 9.0 object library. Chris |
|
#2
|
|||
|
|||
|
Hi
You should use a filter to set filter to the required row count and then proceed with the report preview. |
|
#3
|
|||
|
|||
|
Hi
The following code should do the trick Just before you preview the report, DoCmd.ApplyFilter , "[ID] = '" & Me.Text2.Text & "' " IF the ID is a numeric do not enclose the value within single quotes, else do so. |
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > Print Access Report - VB6 |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|