If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VB code for Unbound Combo Box with table referenced drop down list
The following code always results in the first command being executed,
regardless of the Item, Anthocyanins, Liver_Lipids, Plasma, or ORAC being updated. Can someone help me diagnose my code errors? Private Sub Combo0_AfterUpdate() If Unbound = Anthocyanins Then DoCmd.OpenForm "frmAnthocyanins", acNormal ElseIf Unbound = Liver_Lipids Then DoCmd.OpenForm "frmLiverLipids", acNormal ElseIf Unbound = Plasma Then DoCmd.OpenForm "frmPlasma", acNormal ElseIf Unbound = ORAC Then DoCmd.OpenForm "frmORAC", acNormal End If End Sub |
#2
|
|||
|
|||
VB code for Unbound Combo Box with table referenced drop down list
if your selection is actually those words then they should be surrounded by "
" in your vb however your selection maybe the bound item in a combobox which is not actually the text but a number or someother ID...in which case you would use those values in your vb -- NTC "Such a Beginner" wrote: The following code always results in the first command being executed, regardless of the Item, Anthocyanins, Liver_Lipids, Plasma, or ORAC being updated. Can someone help me diagnose my code errors? Private Sub Combo0_AfterUpdate() If Unbound = Anthocyanins Then DoCmd.OpenForm "frmAnthocyanins", acNormal ElseIf Unbound = Liver_Lipids Then DoCmd.OpenForm "frmLiverLipids", acNormal ElseIf Unbound = Plasma Then DoCmd.OpenForm "frmPlasma", acNormal ElseIf Unbound = ORAC Then DoCmd.OpenForm "frmORAC", acNormal End If End Sub |
#3
|
|||
|
|||
VB code for Unbound Combo Box with table referenced drop down list
This was answered by Clif 4/11/08 4:09PM PST
Subject: Need Help with Code (included in message) but here is my answer.... The first problem is that the items "Anthocyanins", "Liver_Lipids", "Plasma" and "ORAC" need to have quotes around them in the code: Private Sub Combo0_AfterUpdate() If Unbound = "Anthocyanins" Then DoCmd.OpenForm "frmAnthocyanins" ElseIf Unbound = "Liver_Lipids" Then DoCmd.OpenForm "frmLiverLipids" ElseIf Unbound = "Plasma" Then DoCmd.OpenForm "frmPlasma" ElseIf Unbound = "ORAC" Then DoCmd.OpenForm "frmORAC" End If End Sub This is assuming there is a text box named "Unbound". If you don't have a text box named "Unbound", then your code should look something like this: Private Sub Combo0_AfterUpdate() If Me.Combo0 = "Anthocyanins" Then DoCmd.OpenForm "frmAnthocyanins" ElseIf Me.Combo0 = "Liver_Lipids" Then DoCmd.OpenForm "frmLiverLipids" ElseIf Me.Combo0 = "Plasma" Then DoCmd.OpenForm "frmPlasma" ElseIf Me.Combo0 = "ORAC" Then DoCmd.OpenForm "frmORAC" End If End Sub Another option would be using "Select Case" instead of the IF() function: Private Sub Combo0_AfterUpdate() Select Case Me.Combo0 Case "Anthocyanins" DoCmd.OpenForm "frmAnthocyanins" Case "Liver_Lipids" DoCmd.OpenForm "frmLiverLipids" Case "Plasma" DoCmd.OpenForm "frmPlasma" Case "ORAC" DoCmd.OpenForm "frmORAC" End Select End Sub -- Steve S -------------------------------- "Veni, Vidi, Velcro" (I came; I saw; I stuck around.) "Such a Beginner" wrote: The following code always results in the first command being executed, regardless of the Item, Anthocyanins, Liver_Lipids, Plasma, or ORAC being updated. Can someone help me diagnose my code errors? Private Sub Combo0_AfterUpdate() If Unbound = Anthocyanins Then DoCmd.OpenForm "frmAnthocyanins", acNormal ElseIf Unbound = Liver_Lipids Then DoCmd.OpenForm "frmLiverLipids", acNormal ElseIf Unbound = Plasma Then DoCmd.OpenForm "frmPlasma", acNormal ElseIf Unbound = ORAC Then DoCmd.OpenForm "frmORAC", acNormal End If End Sub |
Thread Tools | |
Display Modes | |
|
|