Renabling a disabled field based on another field

clloftus

Registered User.
Local time
Today, 15:51
Joined
Mar 15, 2012
Messages
24
I was able to figure out how to disable a field when another field was filled out; however, when the field is modified to be blank, the 2nd field does not reenable. Below is my code; any assistance you can provide is greatly appreciated.

Private Sub Form _Current()
If Me.VM = -1 Then
Me.txtNSAID.Enabled = True
Me.txtEAID.Enabled = True
Me.cboManufacturerID.Enabled = True

Else
Me.txtNSAID.Enabled = False
Me.txtEAID.Enabled = False
Me.cboManufacturedID.Enabled = False

End if

If Me.txtNSAID = Not Null Then
Me.txtEAID.Enabled = True

Else
Me.txtEAID.Enabled = False

End if

End Sub

Private Sub txtNSAID_AfterUpdate()
If Me.txtNSAID = Not Null Then
Me.txtEAID.Enabled = True

Else
Me.txtEAID.Enabled = False

End if
End Sub

Private Sub txtEAID_AfterUpdate()
If Me.txtEAID = Not Null Then
Me.txtNSAID.Enabled = True

Else
Me.txtNSAID.Enabled = False
End if
End Sub

Private Sub VM_AfterUpdate()
If Me.VM = -1 Then
Me.txtNSAID.Enabled = True
Me.txtEAID.Enabled = True
Me.cboManufacturerID.Enabled = True

Else
Me.txtNSAID.Enabled = False
Me.txtEAID.Enabled = False
Me.cboManufacturerID.Enabled = False
End if
End Sub
 
I'm sorry, that url is a forbidden url from work. Is there something you can provide on this forum?

Thank you for your assistance.
 
If Len(Me.txtEAID & vbNullString) = 0 Then

Tells you the control is Null or has an empty string in it.
 
Where do I place this code in the code that I've shown above? I'm sorry, I'm fairly new to this.

Thanks for your help.
Cindy
 
rather than using -1 for checkboxes (booleans) I would use true and false

so

if vm = true then .... (rather than if vm = -1)

now, you can use nz to coerce a null to a selected value - so in your case simply

if nz(vm,false) = true then

should fix your problem. a blank (null) value is treated as false for the purposes of your test. (note that you can requally assign true to the result of the nz function)
 
No luck.

Problem 1:
When I click the VM checkbox, all of the fields I've requested to be disabled are; however, when adding a new record all of the fields remain disabled until I check/uncheck the checkbox in the new record.

Problem 2:
I have a second checkbox (ITxHub) and have used the same code, but changed the names accordingly; when checking this checkbox absolutely nothing happens.

Problem 3:
When creating a new record, I type in the NSAID field and the EAID field becomes disabled (this is correct); however, when I delete the data in the NSAID field, the EAID field remains disabled .. and vice versa. What I need to happen, I add data into the NSAID field, the EAID field becomes disabled; if I delete the data in the NSAID field both fields become available. The same with the EAID field, if that has data, the NSAID field is disabled, but if the data is removed from the EAID field, both fields are available.

I really appreciate your assistance. This is very mind-boggling, not to mention the hours of frustration I've had trying to figure these out. I can provide the entire code that I'm using if that will help.

Thank you again,
Cindy
 

Users who are viewing this thread

Back
Top Bottom