Solved

MS Access Printing lables with pictures VBA

Posted on 2006-06-21
10
296 Views
Last Modified: 2009-12-16
Hi Experts:
I am developing an Access Application in which user modifies the data. There is an image sitting outside of database in jpeg format. Which shows up in the form. Now I need to print this picture on a lable page with two lables on it. I have crystal reports 8.5 and VB6 and I am good with VB6 but have not used Crystal Reports at all. Again, This app lets users edit a access database table and I need to print Badges from this database table which has name and other info and picture path field in the table points to the jpg picture. The Badge paper is Avery Photo Id badge Inserts #2944. It is 4X6 size and can print two badges. Please provide full example code.
0
Comment
Question by:dhamijap
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
10 Comments
 
LVL 17

Expert Comment

by:Arji
ID: 16966424
Just curious if  you have tried using the label wizard from within Access to try your labels(badges)  You should also be able place a picture on the label just as you would on any report or form.  In fact if you are are already displaying a picture on a form, you can put the form in edit mode and literally copy and paste the picture control from the form to the badg/label.  Of course your printer will be criticial in how it all comes out anyway.
0
 

Author Comment

by:dhamijap
ID: 17266087
I got it myself Thanks for your help
Pradeep
0
 
LVL 17

Expert Comment

by:Arji
ID: 17266339
Please post your solution for the benefit of others on EE.  Also, if you solved the problem yourself, you can close this question by contacting Community Support.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 17

Expert Comment

by:Arji
ID: 17774247
My only objection is that dhamijap didn't post his solution.  I think it would be helpful for the EE database and I'd like to know how it was done.
0
 

Author Comment

by:dhamijap
ID: 17774398
I used the report in ms access here is all the code:

Option Compare Database
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo ErrHandler            
    If LevelCode < 3 Then
        boxBoundry.BackColor = 255
    Else
        boxBoundry.BackColor = 65408
    End If
    lblLogo.BackColor = BadgeFlag
    imgPatientPicture.Picture = PicturePath
    lblDate.Caption = Date
    DoCmd.Restore
Exit Sub
ErrHandler:
Dim sErrorNumber As Long
Dim sErrorDescription As String
    sErrorNumber = Err.Number
    sErrorDescription = Err.Description
    MsgBox "Error Number: " & sErrorNumber & vbCrLf & " Description: " & sErrorDescription
End Sub

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    If Cancel = 0 Then
        DoEvents
    End If
    DoEvents
End Sub

Option Compare Database
Option Explicit

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
On Error GoTo ErrHandler
    lblDate.Caption = Date
    imgPatientPicture.Picture = PicturePath
    If LevelCode < 3 Then
        boxBoundry.BackColor = 255
    Else
        boxBoundry.BackColor = 65408
    End If
    lblLogo.BackColor = BadgeFlag
    DoCmd.Restore
Exit Sub
ErrHandler:
 Dim sErrorNumber As Long
 Dim sErrorDescription As String
    sErrorNumber = Err.Number
    sErrorDescription = Err.Description
    MsgBox "Error Number: " & sErrorNumber & vbCrLf & " Description: " & sErrorDescription
    Resume
End Sub
0
 
LVL 17

Expert Comment

by:Arji
ID: 17775290
Looks good. I have one small suggestion:

This:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
    If Cancel = 0 Then
        DoEvents
    End If
    DoEvents
End Sub

Is the same as this:

Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
     DoEvents
End Sub

Since you are doing DoEvents regardless of whether Cancel = 0 or not, you don't need the If...Then construct.
0
 

Author Comment

by:dhamijap
ID: 17775404
yes u r right I did not look at that just coped and pasted. basically whole sub do not need to be there.
dhamijap
0
 
LVL 1

Accepted Solution

by:
DarthMod earned 0 total points
ID: 17804490
PAQed with points refunded (125)

DarthMod
Community Support Moderator
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question