Solved Scroll through pictures (1 Viewer)

murray83

Games Collector
Local time
Today, 00:39
Joined
Mar 31, 2017
Messages
678
Hi all got a question regarding dlookup, pictures ( hosted within the database ) and how to get it so when the user clicks on a button that it will scroll through the table data and display it on the form.

got some idea of how it would work but not sure how to write it down in code, back of envelope going here

when cmdbutton pressed check database if record then display

have attached file of what i have but has zero code in I'm afraid, grateful for any help or pointers, cheers
 

Attachments

  • sample.accdb
    2.1 MB · Views: 32
Last edited:

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 16:39
Joined
Oct 29, 2018
Messages
18,791
If you display the photos one record at a time, then you should be able to use the GoToRecord method to page through them. Did you want to use a continuous form and scroll through it?
 

murray83

Games Collector
Local time
Today, 00:39
Joined
Mar 31, 2017
Messages
678
Thanks, but no, not a continuous form. Wanted the form to stay static and just the data change when the user clicks either next or previous button
 

Gasman

Enthusiastic Amateur
Local time
Today, 00:39
Joined
Sep 21, 2011
Messages
10,342
So on current event, you get the path of the picture and update the image control?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:39
Joined
Feb 19, 2013
Messages
14,219
guidance.

1. store your pictures in a designated folder (no code rquired)
2. in your tbl_Rouges RougeImage field, store the path to the relevant image (no code required)
3. in your RougesGallery form put tbl_Rouges as the form recordsource (no code required)
4. in that form set the Image0 controlsource to RougeImage (no code required)
5. in that form set the txtRougeBackStory controlsource to RougeBackStory (no code required)
6. also remove your buttons (no code required)
7. also in form properties set the navigation bar to yes (no code required)

use the navigation bar to navigate.

your tbl_Rouges table probably requires more fields - a sort order for example, perhaps a 'storyname' field so you can have multiple stories
 

murray83

Games Collector
Local time
Today, 00:39
Joined
Mar 31, 2017
Messages
678
guidance.

1. store your pictures in a designated folder (no code rquired)
2. in your tbl_Rouges RougeImage field, store the path to the relevant image (no code required)
3. in your RougesGallery form put tbl_Rouges as the form recordsource (no code required)
4. in that form set the Image0 controlsource to RougeImage (no code required)
5. in that form set the txtRougeBackStory controlsource to RougeBackStory (no code required)
6. also remove your buttons (no code required)
7. also in form properties set the navigation bar to yes (no code required)

use the navigation bar to navigate.

your tbl_Rouges table probably requires more fields - a sort order for example, perhaps a 'storyname' field so you can have multiple stories
Thanks shall give that all a go 🙂
 

murray83

Games Collector
Local time
Today, 00:39
Joined
Mar 31, 2017
Messages
678
But what if I wanted to just keep the images in the database as the file path for others wouldn't possibly be the same ??
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:39
Joined
May 7, 2009
Messages
16,116
is it about rougegallery form?
where are the images?
on the demo i am using records from MsysResources
 

Attachments

  • sample.accdb
    2.1 MB · Views: 26

CJ_London

Super Moderator
Staff member
Local time
Today, 00:39
Joined
Feb 19, 2013
Messages
14,219
But what if I wanted to just keep the images in the database as the file path for others wouldn't possibly be the same ??
depends on your app - could have a folder in the same directory as your FE

You can get the filepath for your FE using currentdb.name - strip off the db name add on the foldername and file name

Or if on a server, use the UNC path.


Keeping images in the BE is generally a bad idea you will quickly use up the 2Gb limit
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 19:39
Joined
Feb 19, 2002
Messages
35,925
Storing images in a database just bloats them. Using the UNC path makes the reference to them the same from all users.
 

murray83

Games Collector
Local time
Today, 00:39
Joined
Mar 31, 2017
Messages
678
guidance.

1. store your pictures in a designated folder (no code rquired)
2. in your tbl_Rouges RougeImage field, store the path to the relevant image (no code required)
3. in your RougesGallery form put tbl_Rouges as the form recordsource (no code required)
4. in that form set the Image0 controlsource to RougeImage (no code required)
5. in that form set the txtRougeBackStory controlsource to RougeBackStory (no code required)
6. also remove your buttons (no code required)
7. also in form properties set the navigation bar to yes (no code required)

use the navigation bar to navigate.

your tbl_Rouges table probably requires more fields - a sort order for example, perhaps a 'storyname' field so you can have multiple stories

works a charm but just one question I have which remains. how would i make it loop round as it present i have stuck with the arrow command boxes but when get to last record would like it to just move back to first character/rouge ?

cheers CJ_London
 

CJ_London

Super Moderator
Staff member
Local time
Today, 00:39
Joined
Feb 19, 2013
Messages
14,219
if you are using your own buttons and not the navigation bar you would need to detect that you are at the EOF and goto first record
 

murray83

Games Collector
Local time
Today, 00:39
Joined
Mar 31, 2017
Messages
678
if you are using your own buttons and not the navigation bar you would need to detect that you are at the EOF and goto first record

so would that be something like this again back of envlope thinking

Select ID from tbl_Rouges, loop when EOF
 

moke123

AWF VIP
Local time
Yesterday, 19:39
Joined
Jan 11, 2013
Messages
2,801
heres a navigation bar class . The last argument set to true will cycle through to the first record at EOF and the last record when moving before BOF.

here's all the code needed to implement
Code:
Dim clsNB As clsNavBar

Private Sub Form_Load()

    Set clsNB = New clsNavBar
    clsNB.InitCls Me, Me.bNext, Me.bPrev, Me.bFirst, Me.bLast, Me.bNew

End Sub

The next and previous buttons are required , the rest are optional
 

Attachments

  • NavB.accdb
    640 KB · Views: 20
Last edited:

moke123

AWF VIP
Local time
Yesterday, 19:39
Joined
Jan 11, 2013
Messages
2,801
so would that be something like this again back of envlope thinking

Select ID from tbl_Rouges, loop when EOF
To answer that question, you can test for EOF with
Code:
Me.Recordset.RecordCount = Me.Recordset.AbsolutePosition + 1
to test for BOF
Code:
Me.Recordset.AbsolutePosition = 0
 

murray83

Games Collector
Local time
Today, 00:39
Joined
Mar 31, 2017
Messages
678
heres a navigation bar class . The last argument set to true will cycle through to the first record at EOF and the last record when moving before BOF.

here's all the code needed to implement
Code:
Dim clsNB As clsNavBar

Private Sub Form_Load()

    Set clsNB = New clsNavBar
    clsNB.InitCls Me, Me.bNext, Me.bPrev, Me.bFirst, Me.bLast, Me.bNew

End Sub

The next and previous buttons are required , the rest are optional

works like a charm thanks a million
 

Users who are viewing this thread

Top Bottom