Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    RedEyes is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    14

    A Forms Image Control Problem

    Hi everyone.


    I created a form with an image control on it along with three command buttons (Next, Previous and Close).


    My Table has 3500 records with the path to a folder. The table has two fields ID and ImageName. I run another procedure that brings in the complete path for each file, not the image itself.


    The Query randomly gets photos for the image control.




    The Form is bound to the Query and everything works great, and as, programming goes, I had another idea.


    About having the Image Control default to a Intro Image first before the command button (Next) is pressed. I've been on this for most of the day and have exhausted all avenues' I think.


    Does anyone have an idea of how to go about this?

    Thanks.

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,558
    About having the Image Control default to a Intro Image first before the command button (Next) is pressed.
    That means one time, when the form first opens? I would suggest to code in the load event to get the default/intro image by setting the image control to that image. If it means each time you navigate to a new record in a single record form view, then use the Current event instead.
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

  3. #3
    RedEyes is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    14
    Micron, thanks for your reply but as I stated above the Form is bound to the Query and the Image Control is bound to the Control Source "ImageName". Because of my coding weaknesses, I don't know how to program this idea.

    I thought if a DoCmd was placed in the Forms "On Open" event it would place an image from the Table based on the ImageID referenced in the code. But every Docmd I come up with bombs out in the Editor and that's where I'm stuck. I even looked on the Internet
    for a DoCmd that would grab a ImageID, but haven't found one that works. The image would be one that loads every time the Form opens and from there change each time the Next button is clicked.

    Thanks.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    2,248
    In the open (or load) event of the form add this:

    Code:
    Me.imgControl.Picture=dlookup("[ImageName]","[Query]") 'this will bring up the first record in your query depending on its sort order
    or this:

    Code:
    Me.imgControl.Picture=dlookup("[ImageName]","[Query]","[ImageID] = 150") 'this will bring up ImageID 150
    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    RedEyes is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    14
    Gici, appreciate your response, the second line is what I'm after because it will bring up the default image I want first. What I did was copied that line into Form Load and changed the ID to 3331 and while in the Editor under Debug I click on
    Compile PhotoList it bombs out and highlights .imgControl with a compile error of "Method or data member not found".

    Thanks
    Jim

  6. #6
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,676
    As Vlad is off line - Is you image control called imgControl ?

    If not change it to whatever your image control is called.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    RedEyes is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    14
    The name of the Image Control on the Form is the same as the reference in the code. I had changed the "Me.IngControl" to Me.PhotoFrame as is the name in Properties. It just errors on the line of code, I even check the Editors References to make sure
    everything that's needed was there.

    I'm beginning to suspect that with the Form being Bound to the Query may be the problem. As said above the query is set to Randomize the photos but just to check out something I removed the Query reference from the Row Source. Saved, Closed and re-opened the form and every time it errors and highlights the whole line Yellow.

    Jim

  8. #8
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    2,248
    EDIT: Have you updated everything in the original dLookup expression (ImageName=name of the field holding the path to the images, Query=name of your query,ImageID= unique ID of record in said query) or just the name of the control?


    Hard to debug without seeing your form but lets try something else. In the Open event of the form (leave the image control bound to the query the way you had it before) add the following code:

    Code:
    Dim rs As DAO.Recordset
    
    Set rs = Me.RecordsetClone
    rs.FindFirst "[ID] = " & 3331 'default record image
    Me.Bookmark = rs.Bookmark         
    Set rs = Nothing
    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  9. #9
    RedEyes is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    14
    New Code Error 3070, the whole line rs.FindFirst is highlighted.

  10. #10
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    2,248
    Have you updated the line to use your field name? What is the name of the unique identifier field holding the value 3331?

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  11. #11
    RedEyes is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    14
    The unique identifier is PhotoID which is the Primary Key.
    This what I've done today. Removed the Rnd Field form Query and place PhotoID first in ascending order. Form is still bound to Query, PhotoFrame on form still bound to Photo in query. Form On Load contains one expression the dLookup.
    When Form is opened the PhotoFrame show record 1, it's goes right on by the dLookup that's telling it to open photoID 3331. There isn't anything else I can strip off, it's pretty much straightforward.
    Don't understand why it goes right by dLookup. If I open the query and set the criteria under PhotoId to =3331 the form opens with that Photo 3331.

  12. #12
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    2,248
    Remove the dlookup from the Load event and put there this instead:
    Code:
    Dim rs As DAO.Recordset
    Set rs = Me.RecordsetClone
    rs.FindFirst "[PhotoID] = " & 3331 'default record image
    Me.Bookmark = rs.Bookmark         
    Set rs = Nothing
    You can put your random field back in and sort by it, the code will find the 3331 record and display it on load.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  13. #13
    RedEyes is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2021
    Posts
    14
    Didn't work, it crashes at the same line rs.FindFirst , the entire line is highlighted. This happens with the Randomize in or out of the Query.

  14. #14
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    2,248
    It doesn't actually crash, you are getting a runtime error. Can you please tell us the error number and\or description? Do you have a field named PhotoID in the forms recordsource with the value of 3331 (data type being number)?

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  15. #15
    Minty is online now VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    1,676
    I think we are going to need to see your database or at least a stripped down version of it.

    Something else is not right here.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 09-18-2020, 09:06 PM
  2. Replies: 5
    Last Post: 07-10-2020, 12:41 PM
  3. Replies: 10
    Last Post: 02-25-2019, 07:36 PM
  4. Replies: 2
    Last Post: 03-14-2018, 11:10 AM
  5. Replies: 0
    Last Post: 09-28-2015, 10:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums - Senior Forums