Solved

MS Access Printing lables with pictures VBA

Posted on 2006-06-21
10
292 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
Comment Utility
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
Comment Utility
I got it myself Thanks for your help
Pradeep
0
 
LVL 17

Expert Comment

by:Arji
Comment Utility
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
 
LVL 17

Expert Comment

by:Arji
Comment Utility
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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

Author Comment

by:dhamijap
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed with points refunded (125)

DarthMod
Community Support Moderator
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now