Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Change Properties While a Report
Robert Perrone 
     
16 days ago
I have a picture database; the end goal is to select an individual and print all of his/her tagged pictures in the approximate order of when they were taken. I have the necessary fields in the picture table to sort the photos. The orientation and picture size properties are portrait and zoom for most photos, but some need to be landscape or clip. I have checkboxes in the picture table to take care of this.

I can run three different reports (portrait/zoom, portrait/clip, landscape/zoom) and get the results I want, but the pictures aren't in the correct order (I export them to pdf files). Is there a way to change the orientation and/or picture size properties inside the report based on the checkboxes?
Kevin Yip  @Reply  
     
16 days ago
You create an event procedure in the report's Detail Format event, and set the image's orientation (its SizeMode property) based on conditions you desire.  Sample code:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    ' This procedure runs right before each record is printed

    ' Set picture path based on my string variable
    Me.Image1.Picture = MyVariableWithPicturePath
    
    ' Set picture's size mode property based on my condition
    Select Case MyConditionForSizeMode
        Case condition1: Me.Image1.SizeMode = acOLESizeClip
        Case condition2: Me.Image1.SizeMode = acOLESizeZoom
        Case condition3: Me.Image1.SizeMode = acOLESizeStretch
        Case Else:
    End Select
End Sub


This way, each record on the report will have a picture with its own conditional orientation.

In a continuous form, this cannot be done (the picture's properties must be the same in every record).  But in a report, you can.
Richard Rost  @Reply  
          
16 days ago
Kevin's got the right idea. The Detail_Format event is where you can change the Image control's SizeMode for each record as it is formatted for printing.

One important distinction: SizeMode controls how the image is fit inside the control - Clip, Zoom, or Stretch. It doesn't actually change the report's page orientation. A report is either Portrait or Landscape for the whole print job. You can't switch the printer orientation record by record within one report.

So if your goal is one PDF with the photos in date order, I would make one report sorted by your date/time field, use an Image control large enough for your largest expected photo, and set SizeMode in Detail_Format based on your checkbox field. For example:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

    If Landscape Then
        Image1.SizeMode = acOLESizeZoom
    ElseIf Clip Then
        Image1.SizeMode = acOLESizeClip
    Else
        Image1.SizeMode = acOLESizeZoom
    End If

End Sub

You may also need to adjust the Image control's dimensions or use separate image controls if you truly need different layout areas for portrait versus landscape photos. But for most picture databases, one reasonably sized Image control with acOLESizeZoom works well because it preserves the picture's aspect ratio without cropping it.

Also, make sure the report's Record Source query has the correct ORDER BY on the fields that determine when the picture was taken. Then the records will stay in the proper sequence when you export the report to PDF.
Robert Perrone OP  @Reply  
     
16 days ago
Thank you Kevin and Richard. I will try your recommendations tomorrow.
Kenneth A Thomas  @Reply  
       
15 days ago
GM Robert.  I have over 34,000 pictures in my Google Cloud and I would like to develop a similar database to house copies of at least some of those photos.  Would you be able to share how you setup your table?  I am especially interested in how you link the pictures to the table, as I remember that pictures should not be stored directly in a table.  Thank you.
Robert Perrone OP  @Reply  
     
15 days ago
Hi Kenneth, my wife and I are heading out for breakfast. I’ll answer you when we get back.
Kenneth A Thomas  @Reply  
       
15 days ago
No problem.  Whenever you are ready.
Robert Perrone OP  @Reply  
     
15 days ago
Kenneth, this database stores the location of the pictures, not the pictures themselves. The info below comes directly from Richard's courses and are worth your time to watch. He can explain it much better than I can.

SettingsT table has one field (ImagesFolder) and one record - contains the folder where your pictures are stored.
PictureT table includes PictureID autonumber field and PicFileName - the filename of your photo.

PictureF form loads the ImagesFolder location to an unbound Textbox field called ImagesFolder from the SettingsT table during the On Load event.

DetailsPrivate Sub Form_Load()
    
    ImagesFolder = DLookup("ImagesFolder", "SettingsT")
    If IsNull(ImagesFolder) Or ImagesFolder = "" Then
        MsgBox "No default images folder specified"
    End If

End Sub


To add a record, you can set up a Select File command button to pop up the ImagesFolder to see the photos:

DetailsPrivate Sub SelectFileC_Click()
    
    Dim PathFilename As String
    Dim FilenameOnly As String
    Dim L As Integer
    Dim Ext As String
    
    L = Len(ImagesFolder)

    PathFilename = PickFile(ImagesFolder)
    
    If IsNull(PathFilename) Or PathFilename = "" Then Exit Sub
    FilenameOnly = GetFilenameOnly(PathFilename) 'rick.jpg
    ' check for allowed types .BMP, .GIF, .JPG
    Ext = UCase(Right(FilenameOnly, 3))
    If Ext <> "BMP" And Ext <> "PNG" And Ext <> "JPG" Then
        MsgBox "Not an allowed file type. Only BMP, PNG, JPG allowed."
        Exit Sub
    End If
    
    PicFileName = FilenameOnly
    Me.Refresh
        
    UpdatePicture

End Sub


I'm following Richard's rules and keeping this short.

If that's what you have in mind, you'll need a PickFile function inside the CommonDialog Module. To display the selected picture on your form, you'll need an Image control field called PicFImage. I tag the people who are in this picture with a subform using a PeopleT table (PeopleID field and other info about each person) and PicturePeopleT table (contains PictureID and PeopleID fields).

I hope this helps.
Richard Rost  @Reply  
          
15 days ago
Robert That's exactly the kind of longer post that is perfectly fine. My "keep it short" rule is mainly for someone asking for help and posting 800 lines of code with, "My code isn't working." Nobody wants to debug War and Peace one line at a time.

But when you're helping someone else and explaining how you set something up, more detail is welcome. You gave Kenneth a useful overview, included the important pieces, and pointed him to the lessons for the full explanation. That's good stuff.
Kenneth A Thomas  @Reply  
       
15 days ago
Thank you, Robert.  It looks like this will give me a good start. :)
Robert Perrone OP  @Reply  
     
15 days ago
Kevin and Richard, your tip worked perfectly. Thank you.
Add a Reply Upload an Image
Next Unseen

 
 
What's This?

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 9/21/2026 2:00:16 AM. PLT: 1s