When Check box is checked, insert date.

  • Thread starter Thread starter JG via AccessMonster.com
  • Start date Start date
J

JG via AccessMonster.com

Hi....i have a check box on one of my forms. This form is for invoices.
And when an invoice has been completed, the user clicks the check box,it
inserts the completed date, and disbales all the controls associated with
adding any new orders to that invoice. The problem i am having is when i
open one of the old invoices, the completed date is actually the current
date. I need the date to stay at the completed date, i don't want it to
change, for this will cause some confusion with some of the users. Any
help would be great. Thanks guys!
 
Is the "completed date" field ound to a table? That is the only way to save
the value.

Sounds like you may just have an unbound control that says IF checked, then
CURRENT DATE.

Your code should only fire when the checkbox is changed.
 
Yeah the completed date is a bound field. I think it may be to complicated
for me to show you my code, unless of course you knew what i was doing over
here. Anymore suggestions Rick B?
 
Here is the code for the form's 'On Current' event and the 'On Open' event:

Private Sub Form_Current()
Dim iResponse As Integer

btnPrevious.Enabled = Not Me.CurrentRecord = 1
btnNext.Enabled = Me.CurrentRecord = 1 Or Me.CurrentRecord <
Me.Recordset.RecordCount



If IsNull(Me.CompletedDate) Then
Me.subPowerunits.Enabled = True
End If


If Me!invoicecompleted = True Then
Me!CompletedDate = Date
Me!btnAddPowerunit.Enabled = False
Me.subPowerunits.Enabled = False
Else
If Not IsNull(Me.CompletedDate) Then
iResponse = MsgBox("This invoice has already been completed. Are
you sure you want to change?", vbYesNoCancel, "Warning")
If iResponse = vbYes Then
Me!CompletedDate = ""
Me!btnAddPowerunit.Enabled = True
Me.subPowerunits.Enabled = True
Else
Me.invoicecompleted = True
Me.subPowerunits.Enabled = False
End If
End If
End If

End Sub


Private Sub Form_Open(Cancel As Integer)

If Me!invoicecompleted = True Then
Me.btnAddPowerunit.Enabled = False
Else
Me.btnAddPowerunit.Enabled = True
End If
End Sub
 
There is the line that is causing your problem. The Open Event of the form
Checks to see if the invoice is complete and sets CompletedDate = Date
(which is today's date).

If Me!invoicecompleted = True Then
Me!CompletedDate = Date

Try changing it to this:

If IsNull(Me!CompletedDate) AND Me!InvoiceCompleted = True Then
Me!CompletedDate = Date

You may need to separate that out into a different If statement from the
other things you are doing.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Big List: www.ltcomputerdesigns.com/JCReferences.html
 
Well, that 'current' code says...

As I move from one record to the next, look at my checkbox. If it is TRUE
then stick the current date in the "CompletedDate" field.

All that date logic only needs to happen if the checkbox is CHANGED.
 
Alrighty!.....will try what you suggested. Thanks for being so prompt on
this matter.
 
Back
Top