Enable

D

Dan @BCBS

I'm fustrated: I have 2 combo boxes on a form. I need to say if Combo Box #1
<> "EP" Then Combo Box #2 is not enabled.

If TR_PRODUCT <> "EP" Then
TR_EPOCauseCode.Enabled = False
End If

I've plugged this code into On Load, On Open, On Close. before update.

Don't understand what I'm doing wrong....
 
D

Douglas J. Steele

If you've got a continuous form, you probably need that in the form's
Current event.

You'll also want to ensure it gets called in the AfterUpdate event for Combo
Box #1, so that the status of Combo Box #2 gets refreshed if the value in
Combo Box #1 changes.
 
D

Dan @BCBS

No, it's just a Single Form.
I just added the code below to the AfterUpdate for Combo box #1. and it has
no affect on anything. Combo box #2 is still enabled no matter what is
entered in Combo Box #1.

I'm confused?
 
D

Douglas J. Steele

Try using Me.TR_PRODUCT and Me.TR_EPOCauseCode to ensure they're being
properly recognized as controls on your form.

Are you sure combo box TR_PRODUCT is returning something other than "EP"?
Try putting

MsgBox Me.TR_PRODUCT

into your event: what does it pop up?
 
D

Dan @BCBS

Actually, right after I sent that last message I added Me. but it made no
difference.
Yes, there are many other values than "EP" in TR_PRODUCT..

Could you tell me, should the code be in the Load???

Private Sub Form_Load()

If Me.TR_PRODUCT <> "EP" Then
Me.TR_EPOCauseCode.Enabled = False
End If
 
D

Douglas J. Steele

I'd suggest putting it in the form's Current event.

Did you ensure that Me.TR_PRODUCT returns what you think it does?
 
D

Dan @BCBS

Combo Box 1 (TR_PRODUCT) has a value list: "BD";"BlueOptions
Direct";"EP";"EPO"...etc..

Combo Box 2 (TR_EPOCauseCode) is a select for a table.

The table shows TR_PRODUCT has EP and others (2-EP's and 10527-others.
I am 100% sure the names of the 2 combo boxes are TR_PRODUCT and
TR_EPOCauseCode..

This is my code in the Current
If Me.TR_PRODUCT <> "EP" Then
Me.TR_EPOCauseCode.Enabled = False
End If

I don't see anything wrong?????
Any suggestions???
 
D

Douglas J. Steele

Have you tried single-stepping through the code?

Put a break point in the sub, and make sure it's actually firing.
 
D

Dan @BCBS

I even created a new seperate procedure and I cannot break it down any further:

Private Sub EPOCauseCode()
If Me.TR_PRODUCT <> "EP" Then
Me.TR_EPOCauseCode.Enabled = False
End If
End Sub

This code affects nothing, the combo box remains enabled for any Product.
Let me recap:
1. Created a table called t_EPOCauseCodes
2. Created a value on the table in the SQL database called TR_EPOCauseCode.
3. I updated the link and tested it and it's fine.
4. Created a combo box, table selection (TR_PRODUCT was already part of the
form).
5. Then wrote the code above.

What else is there - I'm confused - this does not seem difficult, but I'm
stumped....
 
D

Dan @BCBS

GOT IT......

I put it back in the current like you suggested and added an else.. it works
fine.
But I did the same thing yesterday and it did not work - bugs me but I don't
care at this point...

Thanks
 
Top