Solved

MS Access Printing lables with pictures VBA

Posted on 2006-06-21
10
294 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
  • 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

776 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