• *.jpg Manager (v2k)

    Author
    Topic
    #391741

    I have a database I am building for a real estate company. I created a single form with the control source set to real estate agents. There is a tab for current homes for sale. Here is where I am struggling:

    * I have a set of jpg photos for each agent of their current homes for sale
    * As you scroll from one agent to the next, I want the homes for that agent to appear in a subform as thumbnail pictures
    * The user could then scroll through all the photos for each broker
    * I am thinking I could create a folder for each agent so the photos could be saved in a specific location for each agent and the database could reference the proper folder
    * My dilemma is how to get the database to pull all the jpg in a scrollable window

    And there is my dilemma. Any help/thoughts, etc. would be appreciated.
    Thanks!

    Viewing 2 reply threads
    Author
    Replies
    • #700944

      Perhaps Thumbs Plus is something for you?

      • #700949

        Hi Hans,
        Thanks a bunch. I reviewed the demo and plan on contacting them but do you know how I could use this in conjunction with a database?
        Thanks,
        Andrew

        • #700950

          Frankly, I don’t know, but I thought you might be able to do something with it since they use an Access database as storage.

          • #700951

            Outstanding. Thanks…I will contact them and if I find any new info, I’ll pass it on.

    • #700955

      Do you need to do it as a continuous form? You could do it as a single subform with navigation buttons and just change the picture property of an image control. One other possiblity is making something that looks like a continuous subform, but is actually 3 (or more) image controls that you change via code — it’s trickier programming, but it would be a neat effect.

      I’ve attached an example of the single form approach.

      HTH, Brent

      • #700963

        The tricky part is how to access the file names. Since they change frequently, I want the database to automatically recognize which jpg files are under each folder without someone having to enter them in a table.
        Your approach about multiple might just do the trick. I am sure there is code that will extract file names from a folder and you’re right about the navigation buttons being a bit trickier with multiple subforms but we all love a challenge.
        Thanks for the advice!!

        • #700993

          Andrew.
          I’ve been working on something like this myself, I’ts not easy.
          I think it would be very tricky holding different pics in different folders.
          Ideally, one folder to hold all the images would be better in reference to the code which has to pull the correct pic.
          It would be difficult to find the correct folder, and then determine which is the correct pic(s).

          Then you have to determine an easy way to name the pic.

          Lets say you have a pic called House1.jpg , you could re-name this with a common identifier:- Branch1-House1.jpg.
          Where you have several pics, if they all had the common identifier, you could filter these from the folder.

          There are many pitfalls here, usually digital cameras, will name the pic in a pre determined format .
          You then have to save them to a location with the prefixed identifier.
          Several pics, renaming them could end up as a labourious task.

          What you’re asking is do-able, but complicated.

          In my situation, I had a little help writing a VB exe program to locate images from a card reader, store the names, add the identifier and then store the image in a pre determined location.
          From here, again with help, filter them out using a complicated Access form and linking them to a particular record.
          Alas the thumbnail scenario hasn’t been accomplished yet but can be done on a report.

          I’m sorry I don’t have an answer to your plight, but if this information helps you, I wish you good luck.

          • #700998

            (Edited by D Willett on 09-Aug-03 12:54. )

            Just a thought.
            If a form had lets say 10 unbound texts.
            A table or query already exists with a field containg an image path.
            Would it be possible to create a loop to fill the unbound texts with path names from the table or query.?

            If so, maybe creating 10 pic controls and referencing them individually to the unbounds to show each pic from the path.

            Would this work ??

            Does anyone already have some loop code to get it started ?

            I ask this because I know a continuous form won’t do it.

        • #701006

          Here is a very simple demo. It contains a form four unbound image controls. Navigation buttons let you scroll through the images in a folder. It also shows clearly that it isn’t very efficient sad

          The demo is in Access 97, zipped. The browse for folder dialog requires Internet Explorer 4 or higher or a recent version of Windows; apart from that, nothing special is used.

          • #701268

            Hans,
            Thanks to you and the others for the help on this one. I was entering new territory and was lost until I received the feedback. The file you sent was outstanding and I really appreciate the extra effort.
            Thanks again and have a great week!
            Andrew

          • #701312

            Outstanding as ever.(knew you’d pick up on this) evilgrin
            I was trying to do something like this over the weekend (there’s a routine in the Courtesy Car Planner to loop and fill)
            Gives me something to start with.

            Thanks again

          • #701336

            Hans

            Is there a way to supress the Import dialog in between loading each pic and, is this advisable ?

            • #701342

              According to Suppress the “Loading Image” dialog on Dev Ashish’s Access Web, you can suppress the dialog with RegEdit. The usual warnings about editing the registry apply. Change the ShowProgressDialog value in HKEY_LOCAL_MACHINESOFTWAREMicrosoftShared ToolsGraphics FiltersImportJPEGOptions from Yes to No. I can’t test it here myself, since the powers that be have protected this registry setting.

            • #701346

              Hans
              Thanks. I found that on Devs site also. Using both methods (Regedit) & (Timer event) don’t work.
              It must be something to do with WinXP or Access version.

              It wasn’t too important, I thought it would just look slicker some how.
              Another thing I was just messing with, changing the bordercolor to vbRed on click.
              Do I need to declare each pic control ?

              Dim i as integer
              for i = 1 to 12
              ‘Yes I’ve expanded it
              Me.Controls(“img” & i).BorderColor = vbRed ??????????
              Next

              Access doesn’t like the expression and hangs.

            • #701350

              I’ll test the registry hack later, on another PC.

              If you want to change the border colour, use something like this (this code is for the sample database, change 4 to 12 in your case)

              Private Function ImgClick(i As Integer)
              Dim j As Integer
              For j = 1 To 4
              If j = i Then
              Me.Controls(“img” & j).BorderColor = vbRed
              Else
              Me.Controls(“img” & j).BorderColor = vbBlack
              End If
              Next j
              End Function

              In the On Click event of img1, enter =ImgClick(1), in that of img2, enter =ImgClick(2), etc., just like the =ImgDblClick(1) etc. entries that are already present in the demo.

            • #701357

              Hans
              Thanks again.

              For those interested in this thread, There are a few modifications.
              Double click the image to fill the Preview box to the right.

            • #701360

              Dave,

              Nice extensions! thankyou

              There was something I hadn’t taken into account in my simple demo: having fewer images in the folder than can be displayed in the form. With 12 images this is more likely to be a problem than with 4, so I have adapted the code slightly to prevent errors if there are fewer images than can be displayed.

            • #701363

              Hans
              Great work. Just to remind every body that all credit goes to Hans for writing this utility which hold countless capabilities if integated within your own database.
              Admitidely ( sorry I can’t spell it) I do push him to the boundaries sometimes evilgrin to make the impossible possible.

              My input and modifications have been purely cosmetic to say the least.
              It just goes to show, that the comunity within the forum are always around to help each other.

              Just a couple of things.
              1.With most camera’s these days, images are mostly stored with the .JPG extension, can the input dialog be removed and except *.jpg instead.
              2.Instead of the scroll going from :
              1 to 12 then 2 to 13 then 3 to 14

              How about 1 to 12 then 13 to 24 etc, so in theory we are stil scrolling, but skipping the images already previewed.
              By this the user will feel he is loading another set of images instead of scrolling.
              evilgrin

            • #701378

              >> How about 1 to 12 then 13 to 24

              Easy: just adapt the number added/subtracted in cmdNext_Click and cmdPrev_Click from 1 to MaxNumberOfImages. You may have to build in an extra check to prevent scrolling past the last image.

            • #701388

              Hans
              Of course, i just hadn’t seen it.
              Thanks again.

              Jez, thanks for the link to Candices site.
              As you can probably see the purpose of this thread was to take that stage one further than Candice’s excellent example.
              Many have often asked for a Thumbnail facility or example, but unfortunately few have come up trumps with it.
              The thumbnail facility can be a useful addition to that and many examples.
              Thanks again.

            • #701412

              OK, here is a version that scrolls by 12 instead of by 1 picture, with checks to prevent scrolling pas the first or last picture.

              This demo is meant as a starting point only, in a production database you wouldn’t prompt for a folder and extension this way. Be aware that loading images can take time, especially on PC’s with a slow processor and/or limited memory.

            • #701414

              Beat me to it.
              I noticed the cmdNext had a “Subscript Out Of Range” when scrolling to the end and run out of images to load.
              Thanks…………..

              Dave

            • #701420

              This version will clear the BorderColor & BorderWidth and et them to 12500670 & 0.
              In addition, the user will not be promted for an extension via the dialog.

            • #701485

              Hmmm, the registry setting that should suppress the “Loading Image” dialog doesn’t work on my Win XP Home / Office XP machine either…

            • #701613

              Hans
              It seems as though it is a WinXP & OfficeXP problem.

              Also can you see any reason why the db has bloated so much.?
              The demo stays at 140kb.
              My db jumped to 64meg, after compacting it went to 38meg.
              Without the recent changes, it was 13meg.

              Should the memory be cleared somehow when the form is closed ?

            • #701618

              Perhaps the picture data get stored somehow. You might try the following:

              – Set the Picture Type property of the image controls to Linked instead of Embedded.
              – Put a command button on the form that closes the form without saving it:
              DoCmd.Close acForm, Me.Name, acSaveNo
              – Set the Close Button property of the form to No, to prevent the user from closing the form by clicking the “x” in the upper roght corner of the form.

            • #701634

              Thanks Hans
              Dropped by 25meg.

            • #701982

              Hans
              I’ve been testing the form and still there seems to be some kind of error.
              I get no error messages, but the image controls still seem to be holding images.
              Opening a record that has images is not a problem, but, some of the records which have no pictures in the folder, still load one image from time to time in img1
              The only thing I’ve added recently is “imgDel” to clear all the pic controls. With this I used “Null” and had type mismatch so changed it to “” instead.
              This held for a while. Should I be using something else to clear the images.
              All the property controls have been adjusted as in your above post.
              Perhaps you can see something in the code which I’ve overlooked.

              Option Compare Database
              Option Explicit

              Private strFolder As String
              Private strExtension As String
              Private arrFileNames(1 To 127) As String
              Private intFileCount As Integer
              Private intCurIndex As Integer
              Private intNumberOfImages As Integer

              Private Const MaxNumberOfImages = 12
              Private Function imgClear()
              Dim g As Integer
              For g = 1 To intNumberOfImages
              Me.Controls(“img” & g).BorderColor = 12500670
              Me.Controls(“img” & g).BorderWidth = 0
              Next g
              End Function

              Private Function imgDel()
              Dim h As Integer
              For h = 1 To intNumberOfImages
              Me.Controls(“img” & h).Picture = “”
              Next h
              End Function

              Private Function imgclick(i As Integer)
              Dim j As Integer
              For j = 1 To intNumberOfImages
              If j = i Then
              Me.Controls(“img” & j).BorderColor = vbRed
              Me.Controls(“img” & j).BorderWidth = 2
              Else
              Me.Controls(“img” & j).BorderColor = 12500670
              Me.Controls(“img” & j).BorderWidth = 0
              End If
              Next j
              End Function

              Private Sub cmdFirst_Click()
              imgClear
              FillImages 1
              End Sub

              Private Sub cmdLast_Click()
              imgClear
              FillImages intFileCount – intNumberOfImages + 1
              End Sub

              Private Sub cmdNext_Click()
              imgClear
              FillImages intCurIndex + MaxNumberOfImages
              End Sub

              Private Sub cmdPrev_Click()
              imgClear
              FillImages intCurIndex – MaxNumberOfImages
              End Sub

              Private Sub FillImages(intIndex As Integer)
              Dim i As Integer
              DoCmd.Hourglass True

              If intIndex > intFileCount – intNumberOfImages + 1 Then
              intIndex = intFileCount – intNumberOfImages + 1
              End If
              If intIndex 1)
              Me.cmdPrev.enabled = (intIndex > 1)
              Me.cmdNext.enabled = (intIndex < intFileCount – intNumberOfImages + 1)
              Me.cmdLast.enabled = (intIndex < intFileCount – intNumberOfImages + 1)
              DoCmd.Hourglass False
              End Sub

              Private Function ImgDblClick(i As Integer)
              Me.txtFilePath = "Path & File Name " & UCase(Me.Controls("img" & i).Picture)
              Me.imgPreview.Picture = Me.Controls("img" & i).Picture
              End Function

              Private Sub cmdLoadImages_Click()
              ' imgDel
              ' imgClear

              ' Dim i As Integer
              ' Dim strFile As String
              ' ' strLeft5 to find left most 5 characters for frmDetails
              ' Dim strLeft5 As String

              ' ' Fixed folder
              ' strFolder = "C:BICImage"

              ' ' Get Left5
              ' strLeft5 = Left(Forms!frmDetails![EstimateNo], 5)

              ' i = 0
              ' ' Get jpg files in strFolder whose names begin with strLeft5
              ' strFile = Dir(strFolder & "" & strLeft5 & "*.jpg")

              ' ' Loop through files
              ' Do While strFile “” And i < 127
              ' i = i + 1
              ' arrFileNames(i) = strFile
              ' strFile = Dir
              ' Loop
              ' intFileCount = i
              ' If intFileCount < MaxNumberOfImages Then
              ' intNumberOfImages = intFileCount
              ' Else
              ' intNumberOfImages = MaxNumberOfImages
              ' End If
              ' FillImages 1
              End Sub

              Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
              Select Case KeyCode
              Case vbKeyF10
              imgClear
              imgDel
              DoCmd.Close acForm, Me.Name, acSaveNo
              Forms!frmDetails.SetFocus
              Forms!frmDetails!DummyEst.SetFocus
              End Select
              End Sub
              Private Sub Form_Load()
              imgDel
              imgClear
              Dim i As Integer
              Dim strFile As String
              ' strLeft5 to find left most 5 characters for frmDetails
              Dim strLeft5 As String

              ' Fixed folder
              strFolder = "C:BICImage"

              ' Get Left5
              strLeft5 = Left(Forms!frmDetails![EstimateNo], 5)

              i = 0
              ' Get jpg files in strFolder whose names begin with strLeft5
              strFile = Dir(strFolder & "" & strLeft5 & "*.jpg")

              ' Loop through files
              Do While strFile “” And i < 127
              i = i + 1
              arrFileNames(i) = strFile
              strFile = Dir
              Loop
              intFileCount = i
              If intFileCount < MaxNumberOfImages Then
              intNumberOfImages = intFileCount
              Else
              intNumberOfImages = MaxNumberOfImages
              End If
              FillImages 1
              End Sub

              Private Sub Form_Open(Cancel As Integer)
              imgClear
              imgDel
              End Sub

            • #701984

              In the imgClear and imgDel functions, the loops have upper limit intNumberOfImages; this is the number of existing images. If there are no images, intNumberOfImages is 0 so nothing gets cleared. Use MaxNumberOfImages as upper limit instead.

              Private Function imgClear()
              Dim g As Integer
              For g = 1 To MaxNumberOfImages
              Me.Controls(“img” & g).BorderColor = 12500670
              Me.Controls(“img” & g).BorderWidth = 0
              Next g
              End Function

              Private Function imgDel()
              Dim h As Integer
              For h = 1 To MaxNumberOfImages
              Me.Controls(“img” & h).Picture = “”
              Next h
              End Function

              Note: the Picture property of an Image control is a string; you can’t set a string property to Null (this is different from a string field in a table, you can set a string field to Null)

            • #701987

              Hans
              Even with the changes , this problem seems specific to this one record 30033 ??

            • #701989

              Dave,

              Does the user close the image form before selecting another record, or does it stay open while the user selects another record in frmDetails?

            • #701991

              Hans
              No. The form has to be closed to gain access to frmDetails. I see what you’re saying and that would make sense.
              Changing the form to Modal also makes no difference.
              The form has no recordsource.
              All the pic controls have a picture property of (None)

              Very strange !!

              Seems like the strFile value “30011” is being held some where, whereas checking the strLeft5 value is correct “30033”
              The attached .png is taken from record “30033”

              ????

            • #701994

              Two more things to try:

              1) Insert an instruction

              Erase arrFileNames

              somewhere near the beginning of Form_Load, before looping through the files. This will clear the contents of the array. Test this first; if it doesn’t help, try the second suggestion.

              2) Replace

              FillImages 1

              near the end of Form_Load by

              If intNumberOfImages > 0 Then
              FillImages 1
              End If

              This really shouldn’t be necessary, but it prevents FillImages from being executed if there are no images.

            • #702009

              (Edited by D Willett on 13-Aug-03 13:37. )

              ***************************
              Maybe something to do with the filename.
              I deleted the images from the root folder and tested again, this time the record was clear.
              I re-named two other images after and the form picked them up ok.
              I’ll keep an eye on it.
              ****************************************************

              Both no joy.

              1st Version:

              Private Sub Form_Load()
              imgDel
              imgClear
              Erase arrFileNames
              Dim i As Integer
              Dim strFile As String
              ‘ strLeft5 to find left most 5 characters for frmDetails
              Dim strLeft5 As String
              ‘ Fixed folder
              strFolder = “C:BICImage”

              2nd Version:

              Else
              intNumberOfImages = MaxNumberOfImages
              End If
              If intNumberOfImages > 0 Then
              FillImages 1
              End If

              End Sub

    • #701380

      Here is another site you may want to look at which has an example of a picture database Candace-Tripp

    Viewing 2 reply threads
    Reply To: *.jpg Manager (v2k)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: