Combo Box Access 2003

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to restrict selecting certain records in a combo box?
Thanks for any help.

Chai
 
Lets say I have an employee table with 10 records. I want all the records to
show up in a bounded combox box, but, I want to restrict certain records from
being selectable. I'm not sure how to word this. Thanks!
 
I have a bounded combox box that pulls records from a table called
tblEmployee that has field names EmployeeID,LastName,FirstName,Current. In
my combo box
I want all records to show, but, don't make those records selectable for
those employees who have, let say, 'No' in the field 'Current'. Thanks.
 
I have a bounded combox box that pulls records from a table called
tblEmployee that has field names EmployeeID,LastName,FirstName,Current. In
my combo box
I want all records to show, but, don't make those records selectable for
those employees who have, let say, 'No' in the field 'Current'. Thanks.

Use the Combo's BeforeUpdate event:

Private Sub cboEmployee_BeforeUpdate(Cancel as Integer)
If Me.cboEmployee.Column(3) = "No" Then
Msgbox "Sorry, not this one", vbOKOnly
Cancel = True
End If
End Sub


John W. Vinson[MVP]
 
John Vinson said:
Use the Combo's BeforeUpdate event:

Private Sub cboEmployee_BeforeUpdate(Cancel as Integer)
If Me.cboEmployee.Column(3) = "No" Then
Msgbox "Sorry, not this one", vbOKOnly
Cancel = True
End If
End Sub

Depending on how the combo box is being used, I'd probably go one step
further, and not include the ones who aren't selectable in the combo box.

You'd do this by using a query to as the RowSource for the combo box, and
have the query exclude the ones marked No.
 
Depending on how the combo box is being used, I'd probably go one step
further, and not include the ones who aren't selectable in the combo box.

You'd do this by using a query to as the RowSource for the combo box, and
have the query exclude the ones marked No.

I would too; but Chai, for whatever reason, specifically said "I want
all the records to show up in a bounded combox box".

I'd find this very frustrating as a user, having names shown but
getting slapped on the hand if I selected one!

John W. Vinson[MVP]
 
I gave it some thought. Yes, I would be frustrated if I wasn't able to
select a record in a bounded combo box. I did what Douglas suggested. Thanks!

Chai
 

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