Got a little problem here...
I have a combo box (Combo5) which needs to make a different field
visible depending on the choice made.
Standard code for what I'm doing is as such:
If Me.Combo5.Value = "2040" Then
Me.OLEOneVal.Vi sible = True
Me.OLETwoVal.Vi sible = False
Me.OLEThreeVal. Visible = False
Me.OLEFourVal.V isible = False
Elseif Me.Combo5.Value = "2041" Then
Me.OLEAetnaTrad itional.Visible = False
Me.OLEPrincipal Financial.Visib le = True
Me.OLEThreeVal. Visible = False
Me.OLEFourVal.V isible = False
Elseif Me.Combo5.Value = "2042" Then
Me.OLEAetnaTrad itional.Visible = False
Me.OLEPrincipal Financial.Visib le = False
Me.OLEThreeVal. Visible = True
Me.OLEFourVal.V isible = False
Elseif Me.Combo5.Value = "2043" Then
Me.OLEAetnaTrad itional.Visible = False
Me.OLEPrincipal Financial.Visib le = False
Me.OLEThreeVal. Visible = False
Me.OLEFourVal.V isible = True
End If
As you can see, each true value sets a different field to visible.
I'd like to do this a little cleaner if possible, to allow for future
expansion, so I'm trying to use variables. I have a table (tblAudits)
with an audit number, audit name and the corresponding field I want
visible on the form. I'm having no luck. My "air code" (which
doesn't work syntactically) goes:
Set db = CurrentDb
Set rec = db.OpenRecordse t("Select * from tblAudits")
'Loop through all possible values
Do While rec.EOF = False
'Get the name of the field from the table
OLED = rec(2).Value
'If the audit number from the table equals the audit number from the
combo box...
If Int(rec(0)) = Int(Me.Combo5.V alue) Then
Me.OLED.Value = False
Else
Me.OLED.Value = True
End If
rec.MoveNext
Loop
Any ideas?
I have a combo box (Combo5) which needs to make a different field
visible depending on the choice made.
Standard code for what I'm doing is as such:
If Me.Combo5.Value = "2040" Then
Me.OLEOneVal.Vi sible = True
Me.OLETwoVal.Vi sible = False
Me.OLEThreeVal. Visible = False
Me.OLEFourVal.V isible = False
Elseif Me.Combo5.Value = "2041" Then
Me.OLEAetnaTrad itional.Visible = False
Me.OLEPrincipal Financial.Visib le = True
Me.OLEThreeVal. Visible = False
Me.OLEFourVal.V isible = False
Elseif Me.Combo5.Value = "2042" Then
Me.OLEAetnaTrad itional.Visible = False
Me.OLEPrincipal Financial.Visib le = False
Me.OLEThreeVal. Visible = True
Me.OLEFourVal.V isible = False
Elseif Me.Combo5.Value = "2043" Then
Me.OLEAetnaTrad itional.Visible = False
Me.OLEPrincipal Financial.Visib le = False
Me.OLEThreeVal. Visible = False
Me.OLEFourVal.V isible = True
End If
As you can see, each true value sets a different field to visible.
I'd like to do this a little cleaner if possible, to allow for future
expansion, so I'm trying to use variables. I have a table (tblAudits)
with an audit number, audit name and the corresponding field I want
visible on the form. I'm having no luck. My "air code" (which
doesn't work syntactically) goes:
Set db = CurrentDb
Set rec = db.OpenRecordse t("Select * from tblAudits")
'Loop through all possible values
Do While rec.EOF = False
'Get the name of the field from the table
OLED = rec(2).Value
'If the audit number from the table equals the audit number from the
combo box...
If Int(rec(0)) = Int(Me.Combo5.V alue) Then
Me.OLED.Value = False
Else
Me.OLED.Value = True
End If
rec.MoveNext
Loop
Any ideas?
Comment