Disable drop down

D

Dan @BCBS

I have 5 items in a dropdown. One of the choices, I'd like ot limit to
specific people.
Is there a way to limit one choice in the dropdown or does it have to all or
nothing???

Thanks
 
B

Barry Gilbert

You could affect the rowsource property by checking the user name when the
form loads. This depends on whether the combo's rowsource is a Table/Query
type or a Value List type. Also, are you using Access security or getting the
user name from Windows or the network login?

Barry
 
D

Dan @BCBS

The data is from a table. One table has the persons info. the other table has
the items in the drop down..
I already Enable a command button on load.

Now I need to enable just one item from another drop down list...


Private Sub Form_Load()
If glevel <> "MANAGER" Then
cmdDelete.Enabled = False

End If

Thanks
 
B

Barry Gilbert

Private Sub Form_Load()
If glevel <> "MANAGER" Then
cmdDelete.Enabled = False
Me.cboCombo.RowSource = "SELECT Blah From tblBlah"
Else
Me.cboCombo.RowSource = "SELECT Blah From tblBlah WHERE YaddaYadda...
End If
End Sub

Barry
 
D

Dan @BCBS

EASY for you to say::
This code give me an error saying "Method or Data Member not found"
(cbo.combo is highlighted).


Private Sub Form_Load()
If glevel <> "MANAGER" Then
cmdDelete.Enabled = False
Me.cboCombo.RowSource = "SELECT tblDecisionCodes.DEC_CODE From
tblDecisionCodes"
Else
Me.cboCombo.RowSource = "SELECT tblDecisionCodes.DEC_CODE From
tblDecisionCodes WHERE (tblDecisionCodes.DEC_CODE = WI)"
End If
End Sub
 
B

Barry Gilbert

I should have mentioned that the control names were changed to protect the
innocent. You need to replace control, table, field names in my example with
your own (unless I lucked out and your combobox is actually named cboCombo).

Barry
 
D

Dan @BCBS

I know this is elementry to you, but I've tried every combination and
Table = tblDecisionCodes (combo box information)
Name of Combo Box = TR_DECISION
Field Name = DEC_CODE
Value I need to capture = WI

This is my most recent failure!
Private Sub Form_Load()
If glevel <> "MANAGER" Then
cmdDelete.Enabled = False
Me.TR_DECISION.RowSource = "SELECT DEC_CODE From tblDecisionCodes"
Else
Me.TR_DECISION.RowSource = "SELECT DEC_CODE From tblDecisionCodes
WHERE (DEC_CODE = WI)"
End If
End Sub

Could you please help me plug in the right controls...
 
B

Barry Gilbert

The one thing that sticks out is that you need to surround WI with single
quotes:
Me.TR_DECISION.RowSource = "SELECT DEC_CODE From tblDecisionCodes WHERE
(DEC_CODE = 'WI')"
Is it failing on this line?

Other than that, I think it looks right.
Barry
 
D

Dan @BCBS

I'm starting to think this cannot be done, again my goal is to have only
Managers be able to choose the WI from a combo box...
//

This code completely disables the combo box (Manager or not):

If glevel <> "MANAGER" Then
cmdDelete.Enabled = False
Me.TR_DECISION.RowSource = "SELECT DEC_DESCRIPTION From
tblDecisionCodes"
Else
Me.TR_DECISION.RowSource = "SELECT DEC_CODE From tblDecisionCodes
WHERE (DEC_CODE = 'WI')"
End If
/////////////////

And this code Enables the combo box for Managers - but not specific to 'WI'

If glevel <> "MANAGER" Then
cmdDelete.Enabled = False

Me.TR_DECISION.RowSource = "SELECT DEC_CODE From tblDecisionCodes
WHERE (DEC_CODE = 'WI')"
End If
/////////////////////
 
Top