Solved Scroll through pictures

murray83

Games Collector
Local time
Today, 22:03
Joined
Mar 31, 2017
Messages
828
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

Last edited:
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?
 
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
 
So on current event, you get the path of the picture and update the image control?
 
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
 
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 🙂
 
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 ??
 
is it about rougegallery form?
where are the images?
on the demo i am using records from MsysResources
 

Attachments

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
 
Storing images in a database just bloats them. Using the UNC path makes the reference to them the same from all users.
 
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
 
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
 
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
 
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

Last edited:
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
 
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

Back
Top Bottom