Solved Form: Onload Event - Images instead of names (1 Viewer)

evictme

Registered User.
Local time
Today, 02:37
Joined
May 18, 2011
Messages
168
Hey all,

I have a small change that I am working on for a control console form I have. Currently, the form includes a sub-form that gives a list of all the users logged into the database.

I am trying to get an image frame to load the corresponding ID picture for each user with the hopes that I can make the sub-form invisible and just use the images to refresh as people log on and off.

I have put together some code for the onload event, that I plan to refresh everytime the sub-form is refreshed. So far it will ONLY show me the last user to log in, i am assuming the most current record. Is this even possible or am i missing something in the code? Ive tried it as individual If statements per user and using the elseif was my most recent attempt...any help would be great!

If Me![Current-Users]![Logged In] = "candy" Then
Me.Image84.Visible = True
Me![Image84].picture = "\\..\candy.jpg"
ElseIf Me![Current-Users]![Logged In] = "echo" Then
Me.Image85.Visible = True
Me![Image85].picture = "\\..\echo.gif"
ElseIf Me![Current-Users]![Logged In] = "xenia" Then
Me.Image86.Visible = True
Me![Image86].picture = "\\..\xenia.jpg"
ElseIf Me![Current-Users]![Logged In] = "applejacks" Then
Me.Image87.Visible = True
Me![Image87].picture = "\\..\applejacks.jpg"
Else
Me.Image87.Visible = False
Me.Image86.Visible = False
Me.Image85.Visible = False
Me.Image84.Visible = False
End If
 

cheekybuddha

AWF VIP
Local time
Today, 08:37
Joined
Jul 21, 2014
Messages
2,277
Is this subform a continuous form?

Your code probably ought to go in the Form_Current event, which will fire each time the form refreshes.

If it is a continuous form then why not just use a single image control. Use an expression/function to set the Picture property.
 

evictme

Registered User.
Local time
Today, 02:37
Joined
May 18, 2011
Messages
168
Is this subform a continuous form?

Your code probably ought to go in the Form_Current event, which will fire each time the form refreshes.

If it is a continuous form then why not just use a single image control. Use an expression/function to set the Picture property.
The subform is displayed as a datasheet. Now I am wondering if it would be easier to use recordset here and reference either the table or the subform.
 

cheekybuddha

AWF VIP
Local time
Today, 08:37
Joined
Jul 21, 2014
Messages
2,277
Ah, I think I see!
[Current-Users] is the subform.
The images are on the main form.

If so, you may not be referring to the subform correctly.

Let us know
 

evictme

Registered User.
Local time
Today, 02:37
Joined
May 18, 2011
Messages
168
Ah, I think I see!
[Current-Users] is the subform.
The images are on the main form.

If so, you may not be referring to the subform correctly.

Let us know
Thank you! I was overthinking it. I just added the imageframe to that subform. Now it shows the users image. However, I had an OnClick event that if I clicked on the user name it would change the name in a combo box on the Main Form. When I added the Onclick event to the picture it only changes to the first record.

Private Sub Image9_Click()
[Forms]![Main]![User] = Me.Logged_In
End Sub
 

evictme

Registered User.
Local time
Today, 02:37
Joined
May 18, 2011
Messages
168
Can you post a screenshot of your form?
form-screenshot.jpg
 

cheekybuddha

AWF VIP
Local time
Today, 08:37
Joined
Jul 21, 2014
Messages
2,277
Is [Forms]![Main]![User] the combo that says 'All Users' ?

If so, what is its ControlSource?
 

evictme

Registered User.
Local time
Today, 02:37
Joined
May 18, 2011
Messages
168
Is [Forms]![Main]![User] the combo that says 'All Users' ?

If so, what is its ControlSource?
Yes. The control source is [User] from table [Users] (bad naming here, I know, but this is only for my use and it's not used outside this form).
 

cheekybuddha

AWF VIP
Local time
Today, 08:37
Joined
Jul 21, 2014
Messages
2,277
OK, just checking it didn't include a hidden column with the UserID
 

evictme

Registered User.
Local time
Today, 02:37
Joined
May 18, 2011
Messages
168
OK, just checking it didn't include a hidden column with the UserID
Not yet.

I know I am missing syntax or something because It works fine if the I click the textbox field with the name of the user but when I click the image from it will only change the user to the first user on the list.
 

cheekybuddha

AWF VIP
Local time
Today, 08:37
Joined
Jul 21, 2014
Messages
2,277
It's a bit weird! It doesn't seem that clicking on the picture is setting the focus to the correct record on the subform.

As a test, try adding a button on top of the picture and add the code to its click event (remove it from the picture click event).

If you get the proper result you can make the button transparent and size it over the whole picture
 

evictme

Registered User.
Local time
Today, 02:37
Joined
May 18, 2011
Messages
168
It's a bit weird! It doesn't seem that clicking on the picture is setting the focus to the correct record on the subform.

As a test, try adding a button on top of the picture and add the code to its click event (remove it from the picture click event).

If you get the proper result you can make the button transparent and size it over the whole picture
Bingo! This works. I suppose it wouldve worked with the other field too. Thank you!
 

evictme

Registered User.
Local time
Today, 02:37
Joined
May 18, 2011
Messages
168
Glad it worked in the end! 👍
Now that I have set it up, it's working great. However, I am having a flickering issue with the images. The form (or at least the images) seem to reload(echo/repaint) anytime I do anything outside that form or even when i go back to that form from somewhere else. It is affecting performance overall. Any chance to reduce the flickering or maybe there is a better way to accomplish what I am trying to do? Any help/ideas?
 

Dreamweaver

Well-known member
Local time
Today, 08:37
Joined
Nov 28, 2005
Messages
2,466
so you loop though the employees table getting each picture then setting it like

Me("Picture" & i).Picture = StrLoc & !Stored

Could you post your code?
 
Last edited:

evictme

Registered User.
Local time
Today, 02:37
Joined
May 18, 2011
Messages
168
so you loop though the employees table getting each picture then setting it like

Me("Picture" & i).Picture = StrLoc & !Stored

Could you post your code?
No. Actually, the list of users is on a subform based on a query that includes an Image container bound to the field [picture]. The subform is displayed as "Continuous" on the main form. The subform includes the fields [Picture], [User], and [Image]. [Image] is the only visible field on the subform.
 

Users who are viewing this thread

Top Bottom