Enable a subform after any selection is made in a combo box

L

lsb

I have a subform "BHUSUBMD" that should remain disabled until an MD
selects their name from a combobox "Seenby". It seems I should use the
On Dirty event but I don't know how the code should look.

I've tried this:

Private Sub SEENBY_Dirty(Cancel As Integer)
Me.Dirty = False

If Me.SEENBY.Value = True Then
BHUSUBMD.Enabled = True
Else
BHUSUBMD.Enabled = False
End If

End Sub

But it's definitely not correct.

Can anyone help?

Thanks,
LB
 
L

lsb

Thanks for responding - have tried it and it's not functioning as
expected. My subform doesn't enable after selecting a item in the
box...
Any further advice?

Best,
LB
 
K

Ken Snell \(MVP\)

Post the RowSource of your combo box; if it's a query, post the SQL
statement. Also identify the bound column value for the combo box. Is the
combo box bound to a field; if yes, what is the datatype of that field? Is
BHUSUBMD the name of the subform control (the control that holds the subform
source object)
 
L

lsb

Here's the info you asked for:

The RowSource of the combo box is part of a query:
SELECT HVHPMDLIST.ID, HVHPMDLIST.MDName FROM HVHPMDLIST ORDER BY
HVHPMDLIST.MDName;

The bound column value for the combobox is 2

The combo box is bound to a field - it is a Text field

BHUSUBMD is the name of the subform control

Thanks,
LB
 
K

Ken Snell \(MVP\)

OK. The query is not giving you a "True/False" value in the bound column. So
let's change the code to this:

Private Sub SEENBY_AfterUpdate()
Me.Dirty = False
BHUSUBMD.Enabled = (Len(Me.SEENBY.Value & """) > 0)
End Sub
 
L

lsb

Ken,
Thank you! The code had one too many "s in it, so I removed one and it
works just great.

LB
 

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

Top