if code help with greying out

tbcwarrior

Registered User.
Local time
Today, 05:53
Joined
Oct 10, 2006
Messages
26
Below is the code that i have made to grey out certain options when you pick certain names in a field

the only issue i have is when i want to look at records already completed, ie if combo box 2 says residential, it should not be greyed out but when i am scrolling through the completed records residential is greyed out is there any additional code i can add to re enable the field when scrolling through records

Private Sub combo2_AfterUpdate()
If Me.combo2.Value = "Commercial - Offices" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Commercial - Industrial unit" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Commercial - Retail unit" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Commercial - Semi commercial" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Commercial - Public house" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Commercial - Hotel" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Commercial - Unit" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Commercial - Factory" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Development (1 Property)" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Development (2 or More Properties)" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Commercial - Other" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Other" Then
Me.combo3.Enabled = False
Me.combo4.Enabled = False
ElseIf Me.combo2.Value = "Residential Farm" Then
Me.combo4.Enabled = True
ElseIf Me.combo2.Value = "Residential" Then
Me.combo4.Enabled = True
Else
Me.combo3.Enabled = True
Me.combo4.Enabled = False
End If
End Sub
 

Attachments

  • example.GIF
    example.GIF
    43.9 KB · Views: 199
Hello:

What you want to do is put the additional code to re-enable the boxes on the OnCurrent event of your form. Then as you go from record to record, the boxes will enable and un-enable as you like.
Regards
Mark
 
copy and paste all your 'if statements' into the 'on current' event
 
hi i have looked through access 2000 and dont see onCurrent command, is this a command for later versions like xp and 2003. or am i just being blind

i have done a screenshot of the properties box i have in 2000

thanks
chris
 

Attachments

  • on command list on properties.GIF
    on command list on properties.GIF
    50.2 KB · Views: 180
or am i just being blind
No, you're just not looking in the right place. You need to look in the FORM's events, not the combo box's.

Also, look into using a Case statement for your "IF's" as it is easier to read and follow.

Example:
Code:
Select Case Me.combo2
    Case  "Commercial - Offices"
      Me.combo3.Enabled = False
      Me.combo4.Enabled = False
    Case "Commercial - Industrial unit"
      Me.combo3.Enabled = False
      Me.combo4.Enabled = False
    Case "Commercial - Retail unit"
      Me.combo3.Enabled = False
      Me.combo4.Enabled = False
    Case "Residential"
      Me.combo4.Enabled = True
    Case Else
      Me.combo3.Enabled = True
      Me.combo4.Enabled = False
End Select
 

Users who are viewing this thread

Back
Top Bottom