Using Record Selectors (1 Viewer)

kirkm

Registered User.
Local time
Today, 16:22
Joined
Oct 30, 2008
Messages
1,257
I'm passing a jpg filename to a Form via Open Args and setting it's picture property.
But if there's a number of pictures how best might I use the Forms record selectors ? Must the forms record source be set to a table or query; or can I use a list ?

Or should I use Current event and write code to do everything, and somehow tell the Form how many pictures there are?

Thanks
 

June7

AWF VIP
Local time
Yesterday, 20:22
Joined
Mar 9, 2014
Messages
5,466
Why are you passing jpg filename to form picture property? You are setting form background image? How could this involve a "number of pictures"?
 

strive4peace

AWF VIP
Local time
Yesterday, 23:22
Joined
Apr 3, 2020
Messages
1,003
hi Kirk,

I saw your other thread, briefly -- you've got a lot of pictures! Best would be to leave them as external files and just store the filename (and path if the paths are different) in a table with your other information about each picture. Then you can use the path\filename in the Control Source of the image control.

Like June mentioned, you don't have to pass the file name. You can use a bound form/report to show the images
 
Last edited:

kirkm

Registered User.
Local time
Today, 16:22
Joined
Oct 30, 2008
Messages
1,257
The Forms job is to show pictures. Is that unusual ??
Hi Crystal, so i put all the filenames into a table and bind the Form to that table. I never know if it's control source, or record source but guess I'll find out. But I don't follow use path\filename in the Control Source of the image control. That would be one picture only, so is that what is changed to show the next picture? Yet if it's bound to something isn't the selection done automatically by the record selectors ?
 

June7

AWF VIP
Local time
Yesterday, 20:22
Joined
Mar 9, 2014
Messages
5,466
Just as a textbox dynamically loads data from record, so will image control. Image control is programmed to handle file path. Control Source can be a text field with full file path or can be an expression that constructs path.
 

strive4peace

AWF VIP
Local time
Yesterday, 23:22
Joined
Apr 3, 2020
Messages
1,003
hi Kirk,

as June said the control source can be a field or an expression that gives you the path\file to your external file! It's perfect! The picture changes for each record ;)
 

kirkm

Registered User.
Local time
Today, 16:22
Joined
Oct 30, 2008
Messages
1,257
This is quite interesting but am floundering a bit. June I don't have a Image control. I just show the image with command Me.Picture = filename
Now I have a table holding the 5 image filenames and have set the Forms recordsource to the table, The record seletor show 1 of 5, 2 of 5 etc but goes on to 6 of 6. There's are only five so something else to sort out! No picture so far, and I'm missing the vital bit how the picture changes for each record. Apart from getitng the filename from the table and assigning it in the Current event. But that's not how its done is it ?
 

kirkm

Registered User.
Local time
Today, 16:22
Joined
Oct 30, 2008
Messages
1,257
Oops just founds out I'm not referring to Record selectors, but the Navigation buttons. Can they be restricted to just the number of records, rather than moving to one more than exists ?
 

Micron

AWF VIP
Local time
Today, 00:22
Joined
Oct 20, 2018
Messages
3,478
I think what you want is to set the form PictureType property to linked, set an initial path to a pic file and then change the path in the form Current event to whatever the pic should be. An image control is probably not relevant here as I suspect your pics are backgrounds for the form.

When you get to 6 of 6 the record is blank yes? That would be because you're allowing your form to append records and 6 is to be a new record. You'd want to set Allow Additions property to No.
 

kirkm

Registered User.
Local time
Today, 16:22
Joined
Oct 30, 2008
Messages
1,257
Thanks Micron, that tip about Allow Additions was beaut.
I've set Picture type to linked and yes, the pics are like backgrounds for the Form.
So, in the current event I'd need to know what picture number is in the Nav buttons. Can that be found or must I handle it myself?
The image filenames are in the table, but if I'm changing the Path/file name in the Current event, do I need the table ? I already have them in an array. Or is the table just so the Form knows the total ?
 

Micron

AWF VIP
Local time
Today, 00:22
Joined
Oct 20, 2018
Messages
3,478
I don't really understand what you're doing. At first it was 'opening a form from another form and setting the background pic via open args' so I'm not sure how the current event or record selectors apply, or what is the point of 'telling' the form how many pics there are. I don't grasp the connection between the record counter number and the picture. Surely the form is for more than just changing form backgrounds, in which case there would be more records than pictures? I think you need to explain what you want to achieve moreso than what you've tried.
 

kirkm

Registered User.
Local time
Today, 16:22
Joined
Oct 30, 2008
Messages
1,257
It's all cool ! Everything's working as desired. The Form just shows Pictures. The Navigation buttons all work . The magic thing was Me.CurrentRecord which gives the index number for the array (and your tip about Allow Additions)
Code:
Private Sub Form_Current()
    Me.Picture = Images(Me.CurrentRecord)
    Me.Caption = StripPath(Images(Me.CurrentRecord))
End Sub

Private Sub Form_Load()
    DoCmd.MoveSize 4100, 500, 7 * 1440, 7 * 1440
End Sub
I'm not using OpenArgs anymore. That gave the filename when there was only one. Now they're in Global array Images.
The table now may be obsolete as the Form is bound to it just to get and show the total beside the Nav buttons. Can I pass the Form that information, Ubound(Images), any other way?
 

kirkm

Registered User.
Local time
Today, 16:22
Joined
Oct 30, 2008
Messages
1,257
Does anyone know what the thing beside the Navigation buttons saying e.g. "Record 1 of 5" is called ?
Trying to Google about that name and "Unbound Form" but getting nowhere !
BTW thanks to you all for ealier replies.. all helped and I see now what you pointed me to control source.
 

Micron

AWF VIP
Local time
Today, 00:22
Joined
Oct 20, 2018
Messages
3,478
Look on the form property sheet Format tab. I think it's just part of the navigation control (Navigation buttons property). If you want to jump to a particular record number, you can type it in yourself, so I've always viewed it as part of that control. Set that property to no and Record Selectors disappears as well. The results of combining the properties seems to depend on characteristics of the form, which might be why so many people think these controls are lacking and they make their own.
 

kirkm

Registered User.
Local time
Today, 16:22
Joined
Oct 30, 2008
Messages
1,257
It's where you could type in a number, as you say and I do want these. What I can't find out is how to have them on an unbound form.
 

June7

AWF VIP
Local time
Yesterday, 20:22
Joined
Mar 9, 2014
Messages
5,466
If form is unbound, there are no records and therefore nothing to navigate.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 00:22
Joined
May 21, 2018
Messages
8,525
Sounds to me you are building a Rube Goldberg Machine
Rude.jpg


I cannot understand why you cannot bind the form to a query with the image paths. Then open to that item with its multiple images. Use the built in navigation selectors to navigate the images. I am guessing that it is likely a subform. If you want to do the background instead of the bound image control then still use the same concept. Then load the image based on the value of the current record. What is the deal with a global image array and unbound "Navigation Controls"? Work smarter not harder.
 
Last edited:

June7

AWF VIP
Local time
Yesterday, 20:22
Joined
Mar 9, 2014
Messages
5,466
@MajP, was "Rude" an intentional pun on "Rube"?

Finally Binged this name and discovered a person who was a cartoonist/sculptor/author/engineer/inventor and Pulitzer Price winner for political cartooning. Wow!
 

kirkm

Registered User.
Local time
Today, 16:22
Joined
Oct 30, 2008
Messages
1,257
Why do want a reason ? It's possible or not? Binding a Form to a query with the image paths was the sort of thing I meant. At the moment I build a table from the array and bind the Form to that. If you could give an unbound Form a count for the navigation buttons that would pass as Me.CurrentRecord, that would work. If not possible, fair enough try something else. I found that an unbound Form gives an error if you try to read Me.Current Record. So really, the question is how to bind a Form to an array? Or as MajP said make a query from image paths. But doesn't a query have to be based on a table? With my existiing table, I don't need a query. Yet, although it works it doesn't feel it's the best or proper way to do it.
 

Users who are viewing this thread

Top Bottom