Using Record Selectors (1 Viewer)

June7

AWF VIP
Local time
Today, 05:12
Joined
Mar 9, 2014
Messages
5,425
Yes, data must be in a table. Then a form can be bound to table or query or have an SQL statement in RecordSource. Not an array.
 

kirkm

Registered User.
Local time
Tomorrow, 02:12
Joined
Oct 30, 2008
Messages
1,257
Seeing I have an array though (and create a table from it) then what I'm doing is as good a method as any ?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:12
Joined
May 21, 2018
Messages
8,463
Seeing I have an array though (and create a table from it) then what I'm doing is as good a method as any ?
No.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 09:12
Joined
May 21, 2018
Messages
8,463

June7

AWF VIP
Local time
Today, 05:12
Joined
Mar 9, 2014
Messages
5,425
See post #17.

Why would you want to employ less efficient method?
 

kirkm

Registered User.
Local time
Tomorrow, 02:12
Joined
Oct 30, 2008
Messages
1,257
These one word answers aren't any help. I read post 17 several times but it didn't really explain or tell me anything that I could understand. I was more mystified after reading it than before. But he also said he didn't understand what I was doing. I did try to put the question as best I could, Anyway it's working fine, but it's always interesting and often worthwhile to see other, possibly better methods. If I'm doing something wrong I'd like to correct it.
 

jdraw

Super Moderator
Staff member
Local time
Today, 09:12
Joined
Jan 23, 2006
Messages
15,364
Anyway it's working fine, but it's always interesting and often worthwhile to see other, possibly better methods. If I'm doing something wrong I'd like to correct it.
How about posting a copy of the database or some graphics of "what is working fine"? How would we know if anything is wrong or what to correct without seeing your requirement and your current solution?
 

kirkm

Registered User.
Local time
Tomorrow, 02:12
Joined
Oct 30, 2008
Messages
1,257
Fair enough But I don't know how much detail you want. My question in Msg#1 says it all and code is in Msg #12.
There's a global array of jpg filenames (called Images) to pass them, via the navigation buttons, to the Form as Me. Picture.
Seems navigation buttons won't work unless the Form is bound. So I make a table from the array, Set the Forms Record Source to it and Open it.
Dim r As DAO.Recordset, i As Integer
DoCmd.SetWarnings False
DoCmd.RunSQL ("Delete * From tblPics")
DoCmd.SetWarnings True
Set r = CurrentDb.OpenRecordset("tblPics")
For i = 1 To UBound(Images)
r.AddNew
r(0) = Images(i)
r.Update
Next
DoCmd.OpenForm "frmPic", acNormal, , , , acWindowNormal
Set r = Nothing

Code:
Private Sub Form_Current()
    Me.Picture = Images(Me.CurrentRecord)
    Me.Caption = StripPath(Images(Me.CurrentRecord))
End Sub
Maybe what is being suggested is as there's now a table bound to the Form containing the data should come from that and not the array. What stopped me was how to set Me.Picture to the current record as I don't have a name for it, only it's index number. Perhaps a recordset and use rx(me.CurrentRecord). But that seemed even more contrived. There's already an array waiting to be used.
So that's the whole deal.
 

isladogs

MVP / VIP
Local time
Today, 13:12
Joined
Jan 14, 2017
Messages
18,186
Have a look at a different approach which works well and involves no arrays.
 

Users who are viewing this thread

Top Bottom