Combo Box Compile Error

  • Thread starter Thread starter AccessFreak via AccessMonster.com
  • Start date Start date
A

AccessFreak via AccessMonster.com

Here's the code:

Private Sub Combo5_Change()
Select Case Me.Combo5.ListIndex
Case "Employee"
List7.Visible
SetValue = True
List9.Visible
SetValue = False
Case "Training"
List7.Visible
SetValue = False
List9.Visible
SetValue = True
End Select
End Sub

Thoughts why I get a "Compile Error: Invalid Use of Property? "Private Sub
Combo5_Change()" is highlighted in the debugger. Thanks!
 
Let me fill you in a little more on what I am up to. I am using a combo box
to select Employees or Training to get a listbox with a "self-run"query to
become visible or invisible based on the combo box selection. Thanks!
 
Here's the code:

Private Sub Combo5_Change()

Use the AfterUpdate event instead - Change() fires at *every
keystroke*.
Select Case Me.Combo5.ListIndex

And just use the default Value property, not the ListIndex. Just
Select Case Me.Combo5
will work correctly.
Case "Employee"
List7.Visible
SetValue = True

and you have two independent statements here, neither of which is
valid. Just

List7.Visible = True

is better.
List9.Visible
SetValue = False
Case "Training"
List7.Visible
SetValue = False
List9.Visible
SetValue = True
End Select
End Sub

Finally, you can do this a lot more simply. First, RENAME YOUR
CONTROLS to something meaningful; but you could just use

Private Sub cboStatus_AfterUpdate()
Me!List7.Visible = (Me!cboStatus = "Employee")
Me!List9.Visible = (Me!cboStatus = "Training")
End Sub

The logical expression will be TRUE or FALSE (assuming that the combo
box only has these two values) and will set the visibility of the
listboxes.

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top