Control image through combobox

luizvin

Registered User.
Local time
Today, 13:08
Joined
Jan 18, 2011
Messages
12
Hy everyone. I'm having a problem with my programming hope somebody can help me.
I want to control an image using a combobox and i'm using the following code:

Private Sub Combo_MED_AfterUpdate()

If Combo_AI.Value = "Complete" Then
Figure13.Visible = True
Figure23.Visible = False
Figure33.Visible = False


ElseIf Combo_MED.Value = "In Process" Then
Figure13.Visible = False
Figure23.Visible = True
Figure33.Visible = False


ElseIf Combo_MED.Value = "Nothing" Then
Figure13.Visible = False
Figure23.Visible = False
Figure33.Visible = True


Else
Figure13.Visible = False
Figure23.Visible = False
Figure33.Visible = False

End If

End Sub

Everything is going well and the image that i put in the form is changing according to the value in the combobox, the problem is when i close and open the form again, the image does not match with the value in the combobox.
Can somebody help me please.
Thanks.
 
To keep a form in-sync with the combobox use the Forms OnCurrent event. Either repeat the code there or call the afterUpdate event of your combobox.

Ex:

Code:
Private Sub Form_OnCurrent()
Call Combo_MED_AfterUpdate()
End Sub

JR
 
OK JR. Thanks for your reply. i still having some problems. i don't know if there is some relationship but i'm using the access 2007 to do this program
I did this code:
Private Sub Student_Detail_OnCurrent()
Call Combo_MED_AfterUpdate

If Combo_APP.Value = "Complete" Then
Figure1.Visible = True
Figure2.Visible = False
Figure3.Visible = False


ElseIf Combo_APP.Value = "In Process" Then
Figure1.Visible = False
Figure2.Visible = True
Figure3.Visible = False


ElseIf Combo_APP.Value = "Nothing" Then
Figure1.Visible = False
Figure2.Visible = False
Figure3.Visible = True


Else
Figure1.Visible = False
Figure2.Visible = False
Figure3.Visible = False

End If
End Sub

But sounds like does not recognize the statement.
well i didn't mentioned before but i'm using 13 different combobox in the same tab.
Thanks
 
Last edited:
Private Sub Student_Detail_OnCurrent()

No you don't use the formname!! just

Private Sub Form_OnCurrent()
etc.

If you got to the property of your form and under Events you find it. Its the first one on the list. Make sure that it contains this:

[Event Procedure]

Hope I spelled it correctly :o

JR
 
I tried this before but still giving me some error messages:

[FONT=&quot]The expression On Current you entered as the event property setting produced the following error Ambiguous name detected: [/FONT]
[FONT=&quot]Form-Current [/FONT]
[FONT=&quot]expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]. [/FONT]
[FONT=&quot]may have been an error evaluating the function, event, or macro. [/FONT]

So i tried to change to Private Sub Form_Current ( ) to every combobox that I have but still calling the same problem
I think the problem is because i'm using 13 different comboboxes, but i tried to Call the 13 comboboxes with the Private Sub Form_Current ( ), and nothing
 
Last edited:
Here is a visual on how to to use codes on a form :http://www.btabdevelopment.com/ts/eventcode

The expression On Current you entered as the event property setting produced the following error Ambiguous name detected

That's because you now have 2 or more of this code line:

Private Sub Form_OnCurrent()

You can ONLY have 1!!!!!!!! in a form module. Get rid of the surplusses.

So i tried to change to Private Sub Form_Current ( ) to every combobox

:confused::confused:

Either post a copy of you db or post you entire Formmodule code so we can clean it up.

JR
 
Thanks for reply, the code is pretty big because i'm using 13 different comboboxes to control the images.
I did some changes at the programming. i tried to put only one Private Sub Form_Current() instead 13 different, but did not work very well.
I also have two different programs at the end
Hope that helps thanks a lot


Private Sub Form_Current()
Call Combo_APP_AfterUpdate

If Combo_APP.Value = "Complete" Then
Figure1.Visible = True
Figure2.Visible = False
Figure3.Visible = False


ElseIf Combo_APP.Value = "In Process" Then
Figure1.Visible = False
Figure2.Visible = True
Figure3.Visible = False


ElseIf Combo_APP.Value = "Nothing" Then
Figure1.Visible = False
Figure2.Visible = False
Figure3.Visible = True


Else
Figure1.Visible = False
Figure2.Visible = False
Figure3.Visible = False

End If



Call Combo_FIN_AfterUpdate

If Combo_FIN.Value = "Complete" Then
Figure11.Visible = True
Figure21.Visible = False
Figure31.Visible = False


ElseIf Combo_FIN.Value = "In Process" Then
Figure11.Visible = False
Figure21.Visible = True
Figure31.Visible = False


ElseIf Combo_FIN.Value = "Nothing" Then
Figure11.Visible = False
Figure21.Visible = False
Figure31.Visible = True


Else
Figure11.Visible = False
Figure21.Visible = False
Figure31.Visible = False

End If




Call Combo_BIO_AfterUpdate

If Combo_BIO.Value = "Complete" Then
Figure12.Visible = True
Figure22.Visible = False
Figure32.Visible = False


ElseIf Combo_BIO.Value = "In Process" Then
Figure12.Visible = False
Figure22.Visible = True
Figure32.Visible = False


ElseIf Combo_BIO.Value = "Nothing" Then
Figure12.Visible = False
Figure22.Visible = False
Figure32.Visible = True


Else
Figure12.Visible = False
Figure22.Visible = False
Figure32.Visible = False

End If



Call Combo_MED_AfterUpdate

If Combo_MED.Value = "Complete" Then
Figure13.Visible = True
Figure23.Visible = False
Figure33.Visible = False


ElseIf Combo_MED.Value = "In Process" Then
Figure13.Visible = False
Figure23.Visible = True
Figure33.Visible = False


ElseIf Combo_MED.Value = "Nothing" Then
Figure13.Visible = False
Figure23.Visible = False
Figure33.Visible = True


Else
Figure13.Visible = False
Figure23.Visible = False
Figure33.Visible = False

End If




Call Combo_SCHOL_AfterUpdate

If Combo_SCHOL.Value = "Complete" Then
Figure14.Visible = True
Figure24.Visible = False
Figure34.Visible = False


ElseIf Combo_SCHOL.Value = "In Process" Then
Figure14.Visible = False
Figure24.Visible = True
Figure34.Visible = False


ElseIf Combo_SCHOL.Value = "Nothing" Then
Figure14.Visible = False
Figure24.Visible = False
Figure34.Visible = True


Else
Figure14.Visible = False
Figure24.Visible = False
Figure34.Visible = False

End If




Call Combo_TOEFL_AfterUpdate

If Combo_TOEFL.Value = "Complete" Then
Figure15.Visible = True
Figure25.Visible = False
Figure35.Visible = False


ElseIf Combo_TOEFL.Value = "In Process" Then
Figure15.Visible = False
Figure25.Visible = True
Figure35.Visible = False


ElseIf Combo_TOEFL.Value = "Nothing" Then
Figure15.Visible = False
Figure25.Visible = False
Figure35.Visible = True


Else
Figure15.Visible = False
Figure25.Visible = False
Figure35.Visible = False

End If



Call Combo_I20_AfterUpdate

If Combo_I20.Value = "Complete" Then
Figure16.Visible = True
Figure26.Visible = False
Figure36.Visible = False


ElseIf Combo_I20.Value = "In Process" Then
Figure16.Visible = False
Figure26.Visible = True
Figure36.Visible = False


ElseIf Combo_I20.Value = "Nothing" Then
Figure16.Visible = False
Figure26.Visible = False
Figure36.Visible = True


Else
Figure16.Visible = False
Figure26.Visible = False
Figure36.Visible = False

End If




Call Combo_SEV_AfterUpdate

If Combo_SEV.Value = "Complete" Then
Figure17.Visible = True
Figure27.Visible = False
Figure37.Visible = False


ElseIf Combo_SEV.Value = "In Process" Then
Figure17.Visible = False
Figure27.Visible = True
Figure37.Visible = False


ElseIf Combo_SEV.Value = "Nothing" Then
Figure17.Visible = False
Figure27.Visible = False
Figure37.Visible = True


Else
Figure17.Visible = False
Figure27.Visible = False
Figure37.Visible = False

End If




Call Combo_VISA_AfterUpdate

If Combo_VISA.Value = "Complete" Then
Figure18.Visible = True
Figure28.Visible = False
Figure38.Visible = False


ElseIf Combo_VISA.Value = "In Process" Then
Figure18.Visible = False
Figure28.Visible = True
Figure38.Visible = False


ElseIf Combo_VISA.Value = "Nothing" Then
Figure18.Visible = False
Figure28.Visible = False
Figure38.Visible = True


Else
Figure18.Visible = False
Figure28.Visible = False
Figure38.Visible = False

End If




Call Combo_HAPP_AfterUpdate

If Combo_HAPP.Value = "Complete" Then
Figure19.Visible = True
Figure29.Visible = False
Figure39.Visible = False


ElseIf Combo_HAPP.Value = "In Process" Then
Figure19.Visible = False
Figure29.Visible = True
Figure39.Visible = False


ElseIf Combo_HAPP.Value = "Nothing" Then
Figure19.Visible = False
Figure29.Visible = False
Figure39.Visible = True


Else
Figure19.Visible = False
Figure29.Visible = False
Figure39.Visible = False

End If




Call Combo_HDEP_AfterUpdate

If Combo_HDEP.Value = "Complete" Then
Figure110.Visible = True
Figure210.Visible = False
Figure310.Visible = False


ElseIf Combo_HDEP.Value = "In Process" Then
Figure110.Visible = False
Figure210.Visible = True
Figure310.Visible = False


ElseIf Combo_HDEP.Value = "Nothing" Then
Figure110.Visible = False
Figure210.Visible = False
Figure310.Visible = True


Else
Figure110.Visible = False
Figure210.Visible = False
Figure310.Visible = False

End If




Call Combo_AINF_AfterUpdate

If Combo_AINF.Value = "Complete" Then
Figure111.Visible = True
Figure211.Visible = False
Figure311.Visible = False


ElseIf Combo_AINF.Value = "In Process" Then
Figure111.Visible = False
Figure211.Visible = True
Figure311.Visible = False


ElseIf Combo_AINF.Value = "Nothing" Then
Figure111.Visible = False
Figure211.Visible = False
Figure311.Visible = True


Else
Figure111.Visible = False
Figure211.Visible = False
Figure311.Visible = False

End If




Call Combo_DEPT_AfterUpdate

If Combo_DEPT.Value = "Acepted" Then
Figure112.Visible = True
Figure212.Visible = False
Figure312.Visible = False


ElseIf Combo_DEPT.Value = "Process" Then
Figure112.Visible = False
Figure212.Visible = True
Figure312.Visible = False


ElseIf Combo_DEPT.Value = "Sent" Then
Figure112.Visible = False
Figure212.Visible = False
Figure312.Visible = True


Else
Figure112.Visible = False
Figure212.Visible = False
Figure312.Visible = False

End If
End Sub

Private Sub Command464_Click()

On Local Error GoTo Some_Err

Dim MyDB As Database, RS As Recordset
Dim strBody As String, lngCount As Long, lngRSCount As Long

DoCmd.RunCommand acCmdSaveRecord
Set MyDB = DBEngine.Workspaces(0).Databases(0)

Me!txtProgress = Null

Set RS = MyDB.OpenRecordset _
("Email - Outstanding Promos")
lngRSCount = RS.RecordCount
If lngRSCount = 0 Then
MsgBox "No promo email messages to send.", vbInformation
Else
RS.MoveLast
RS.MoveFirst
Do Until RS.EOF
lngCount = lngCount + 1
lblStatus.Caption = "Writing Message " & CStr(lngCount) _
& " of " & CStr(lngRSCount) & "..."
strTo = RS!cEmailAddress
intMessageID = Year(Now) & Month(Now) & Day(Now) & Fix(Timer) & "_MabryMail"

' Send the email using some technique or other

RS.Edit
RS("cpeDateTimeEmailed") = Now()
RS.Update
RS.MoveNext
Loop

End If
RS.Close
MyDB.Close
Set RS = Nothing
Set MyDB = Nothing
Close

Me!txtProgress = "Sent " & CStr(lngRSCount) & " emails."
lblStatus.Caption = "Email disconnected"
MsgBox "Done sending Promo email. ", vbInformation, "Done"
lblStatus.Caption = "Idle..."
Exit Sub

Some_Err:
'MousePointer = 0
MsgBox "Error (" & CStr(Err.Number) & ") " & Err.Description, _
vbExclamation, "Error!"
lblStatus.Caption = "Email disconnected"

End Sub


Public Function Greet()
Dim strMsg As String

If Time < #12:00:00 PM# Then
strMsg = "Helo! Good Morning!"
ElseIf Time <= #7:00:00 PM# Then
strMsg = "Helo! Good Afternoon!"
Else
strMsg = "Helo! Good Night!"

End If
Greet = strMsg
End Function
 
Could somebody help me with this code please?
I still having problem with that.
 
This is what I ment should go in the OnCurrent Event:

Code:
Private Sub Form_OnCurrent()
    Call Combo_APP_AfterUpdate()
    Call Combo_FIN_AfterUpdate()
    Call Combo_BIO_AfterUpdate()
    Call Combo_MED_AfterUpdate()
    Call Combo_SCHOL_AfterUpdate()
    Call Combo_TOELF_AfterUpdate()
    Call Combo_I20_AfterUpdate()
    Call Combo_SEV_AfterUpdate()
    Call Combo_VISA_AfterUpdate()
    Call Combo_HAPP_AfterUpdate()
    ... etc
End Sub

JR
 
This is what I ment should go in the OnCurrent Event:

Code:
Private Sub Form_OnCurrent()
    Call Combo_APP_AfterUpdate()
    Call Combo_FIN_AfterUpdate()
    Call Combo_BIO_AfterUpdate()
    Call Combo_MED_AfterUpdate()
    Call Combo_SCHOL_AfterUpdate()
    Call Combo_TOELF_AfterUpdate()
    Call Combo_I20_AfterUpdate()
    Call Combo_SEV_AfterUpdate()
    Call Combo_VISA_AfterUpdate()
    Call Combo_HAPP_AfterUpdate()
    ... etc
End Sub
JR


Thanks for reply again and try to help me.
I tried this code before but with that the image in the form doesn't change.
When i put just "Private Sub Form_Current()" it showed me in the properties of the form the event On Current, but when i change the code to OnCurrent it doesn't show anything in that event.
 
Sorry it should be :o

Private Sub Form_Current()

See attached demo DB, use the navigationbuttons to go through the records and see the changes

JR
 

Attachments

Last edited:
Sorry it should be :o

Private Sub Form_Current()

See attached demo DB, use the navigationbuttons to go through the records and see the changes

JR

That was great JANR, Thanks a lot
It works properly
Do you think if i could use some of this codes to control image in a "report"?

Thanks again
 

Users who are viewing this thread

Back
Top Bottom