Fields conditionally available

Stuart Green

Registered User.
Local time
Today, 15:08
Joined
Jun 24, 2002
Messages
108
I have a form that includes a yes/no tick box (field is called [dm_wo_ind] in the code below) that is completed when a case has been finished (this is done via an update query). If the tick box is completed, then I do not want some of the fields on the record to be subsequently enabled. I have tried putting the following code to the On Current event of the form but it just disables the fields regardless, even for new records. Any suggestions please. Just tipping the toe in the coding water!

Private Sub Form_Current()
If (Not IsNull([dm_wo_ind])) Then
dm_action_end.Enabled = no
reasonfinished.Enabled = no
Else
dm_action_end.Enabled = yes
reasonfinished.Enabled = yes

End If
 
Code:
Private Sub Form_Current()

     If Me.dm_wo_ind = True Then
          Me.dm_action_end.Enabled = False
          Me.reasonfinished.Enabled = False
     Else
          Me.dm_action_end.Enabled = True
          Me.reasonfinished.Enabled = True
     End If

 Me.Form.Requery

End Sub
Is it a single or continuous form?
 
Last edited:
It's a single form. When I tried the code you suggest the requery seems to get the form stuck into a continuous calculation loop
 
Stuart Green said:
It's a single form. When I tried the code you suggest the requery seems to get the form stuck into a continuous calculation loop
My mistake :o
Replace that with..
Code:
     Me.Form.Refresh
Do you run the Update query from a button on the form? If so, call the OnCurrent event after the query has run. Place the following under the code that runs the query.
Code:
     Call Form_Current
HTH
 
Well, don't I feel like the proverbial horse's backside! Had a look at the table and the indicator field has a default value of 0. Changed the criteria from not isnull, to =-1 and it worked a treat
Many thanks for the code however as even my original attempt wouldn't work with =-1. Lesson learned here....don't be lazy with the field names, use me. and don't use "yes and no", true or false is correct.
Thanks once again, you have been a great help
 
Glad you got it sorted.
 

Users who are viewing this thread

Back
Top Bottom