Form Update Question

CheckBoxes have an AfterUpdate event. Have you tried setting the ExpireDate when you set the CheckBox?
 
Are you sure your values are -1 and 1 and not -1 and 0?
 
Sorry, -1 and 0 your right. I just tryed to set it in the afterupdate of the [Continous Entry] Checkbox. It still does not update until i click to a new record then click back again. However i tryed to put it on the "onclick" property and it updates after i click it, however it will only update the [status] filed but will not generate the expire date.

Code:
Private Sub Check67_Click()
If Me![Continous Entry] = True Then
      Me![ExpireDate] = DateAdd("yyyy", 1, Me![Approval Date])
      End If
   If Me![Daily Entry] = True Then
      Me![ExpireDate] = Me![To]
   End If
   If Me![Daily Entry] = False And Me![Continous Entry] = False Then
      Me![ExpireDate] = Me![ExpireDate]
   End If
   If Me.ExpireDate > Now Then
      Me.Status = "Cleared"
   Else
      Me.Status = "Expired"
   End If
End Sub
 
Last edited:
Sorry, -1 and 0 your right.
Good!
Let's take this one step at a time. Is the [Continous Entry] field bound to the Check67 control? (Do you have it as the ControlSource of the Check67 control?) Do you show the [ExpireDate] field in a control on your form?
 
If Me![Daily Entry] = False And Me![Continous Entry] = False Then
Me![ExpireDate] = Me![ExpireDate]
What's the point of this bit of code?:confused:
 
Rich,
If you look back at the beginning of this thread you will see even the OP did not think it made any sense and I agreed. We're slowly but surely revising the code so it does what the OP wants.
 
Thanks Guys! Have been away for a few days but am back at it again.
Yes, the [Continous Entry] field is bound to the Check67 control. [Expiredate] is shown on my form and is locked for editing by the user. One thing I figured out is the [ExpireDate] filed will update itself if I click on the textbox bound to [ExpireDate]in the form field and then click off of it. Does this have something to do with where the focus is set? Thanks Again!
 
The Me.ExpireDate control should update as soon as you click the checkbox. Change the name of the control bound to the ExpireDate field to txtExpireDate so we can differentiate the two. The try to change the control and not the field.
 
Changed the name to txtExpireDate. Control source is set to [ExpireDate]. [Expire Date] Still not updating after check. However [Status] is updating just fine after check.

Code:
Private Sub Check67_Click()
If Me![(Continous Entry)] = True Then
      Me![ExpireDate] = DateAdd("yyyy", 1, Me![(Approval Date)])
      End If
   If Me![(Daily Entry)] = True Then
      Me![ExpireDate] = Me![To]
   If Me.ExpireDate > Now Then
      Me.Status = "Cleared"
   Else
      Me.Status = "Expired"
   End If
End Sub
 
Last edited:
Now change the Click event code to:
Code:
Private Sub Check67_Click()
   Me.txtExpireDate = DateAdd("yyyy", 1, Me![Approval Date])
End Sub
Does it set the txtExpiredate control?
 
I think I have it working now. I removed the "Status" field all together. As the querys can run from the [Expire Date] field with a requirment of >=Now for the expired list query. This also fixes the field update problem beacuse im using a query. Thank you so much for you code help. Here is how i have my form setup now.

Code:
Private Sub Check67_Click()
Me.[ExpireDate] = DateAdd("yyyy", 1, Me![Approval Date])
End Sub

And this is for the daily entry, I removed the checkbox all together and set it to update the expiredate to the [To] field after the txtbox is filled out.

Code:
Private Sub Entry_To_BeforeUpdate(Cancel As Integer)
Me.[ExpireDate] = Me![To]
End Sub

Its amazing how the simplest code works best! Thanks RuralGuy.
 
Even though the following code works, I would put this code in the AfterUpdate event and not in the BeforeUpdate event. Unless there are spaces in the name it is not necessary to surround a control name with [brackets]!
Code:
Private Sub Entry_To_BeforeUpdate(Cancel As Integer)
Me.[ExpireDate] = Me![To]
End Sub
 

Users who are viewing this thread

Back
Top Bottom