Enabling Text Boxes Problem????? Please Help??

motoxracer400f

Registered User.
Local time
Today, 09:50
Joined
Feb 14, 2008
Messages
11
:confused: Hi,

I've used Visual Basics in the past and havn't had to many problems, but I am using Acess 2007 and am bit new to it and I just can't get this darn thing to work. Can someone please help me?

Here's the problem:

I have a form with a combo box and many text fields on it. There are a few tables that store all the information that I am accessing as well. I have a combo list box on this form called "Part" that pulls values from one of those table. I am trying to get all the text boxes to enable/unable based on what I select from the combo box. I thought I had it coded right, but when I run the form nothing even happens (everything is still enabled). What is going on with this????? What am I doing wrong?

Here is the code I am using:

Code:
Sub DisableAll()

'Disable all controls

    Me.Customer.Enabled = False
    Me.CustomerDWGNumber.Enabled = False
    Me.Description.Enabled = False
    Me.Material.Enabled = False
    Me.UNSNumber.Enabled = False
    Me.GaugeThickness.Enabled = False
    Me.Notes.Enabled = False
    Me.UnitOfMeasurement.Enabled = False
    Me.Length.Enabled = False
    Me.Width.Enabled = False
    Me.Height.Enabled = False
    Me.Diameter.Enabled = False
    Me.OD.Enabled = False
    Me.PipeOD.Enabled = False
    Me.CenterCenter.Enabled = False
    Me.Taper.Enabled = False
    Me.HoleCenterCenter.Enabled = False
    Me.CenterCanThickness.Enabled = False
    Me.CenterCanHeight.Enabled = False
    Me.ICDesign.Enabled = False
    Me.ICStyle.Enabled = False
    Me.LiftingType.Enabled = False
    
End Sub

Private Sub Form_Load()
    Call DisableAll
End Sub

Private Sub Part_BeforeUpdate(Cancel As Integer)
Call DisableAll

    Select Case Me.Part
'Baskets
        Case "BA01"
            Me.Material.Enabled = True
            Me.OD.Enabled = True
            Me.Length.Enabled = True
            Me.Width.Enabled = True
            Me.Height.Enabled = True
            Me.Notes.Enabled = True
        Case "BA02"
            Me.Material.Enabled = True
            Me.OD.Enabled = True
            Me.Length.Enabled = True
            Me.Width.Enabled = True
            Me.Height.Enabled = True
            Me.Notes.Enabled = True
        Case "BA03"
            Me.Material.Enabled = True
            Me.OD.Enabled = True
            Me.Length.Enabled = True
            Me.Width.Enabled = True
            Me.Height.Enabled = True
            Me.Notes.Enabled = True
        Case Else
    End Select
End Sub
 
At a glance the code appears to be correct. I would try step debugging the code to see where it is going.
 
you probably need this stuff in the forms current event, to do it on each new record

you are probably better putting the enables etc in the part afterupdate rather than before update

do you mean the various fields are enabled irrespective of whatever you try to do?

are you setting "part" programatically. if so you wont get control events firing. these will only fire if you ebtire text or select a drop down. perhaps that is the probelm
 
Yes, all the fields still stay enabled and nothing seems to happen no matter what code I put in. I'm thinking it has something to do with me pulling the information from tables and the code doesn't see those values or something. How do I get the table information to become part of the form so it recognizes it? Is there something I am doing wrong? This is driving me crazy. Thanks for the help!!!
 
How do I get the table information to become part of the form so it recognizes it?
The form's record source needs to be the name of your table or a query that queries your table.

As far as the text boxes/fields: Material, OD, Length, etc, are those the "names" of your text boxes or the control source property? Or are the name and control source property the same (as the form wizard names them)? It's not recommended to have the control source and the name be the same as it can cause confusion in some cases. You should use names like txtMaterial, txtOD, txtLength, etc.... and when you want to enable/disable the text box you need to refer to the name of it, not the control source.

If you still can't figure it out, post a condensed DB with a copy of your form and table with a few records in it...
 
I am refering to the textbox name not control source. I renamed some of them to differ from the control source name and also just changed the code to this orientation so that there wouldn't be any conflicts:

Code:
Forms![Form]![Notes].Enabled = True

Still nothing at all happens. I don't understand.
 
Can you post a db containing your form and table?
 
I installed the SP1 update and all my problems were fixed!!!! It must have been a bug. Thanks for all your help!!!
 

Users who are viewing this thread

Back
Top Bottom