Retaining previouse True/False Value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Win XP and Access 03.

I have a true/false field called "Consigned" in the third tab of a form. I
want for the value recorded on the last record to automatically be recorded
on a new record created. I have the code below, but it isn't working... any
ideas? Is there a difference when it is boolian True/False?

Private Sub consigned_AfterUpdate()
'remembers last consignment setting for new record
Me!Consigned.DefaultValue = Me!Consigned
End Sub
 
DefaultValue is a string property.

Try:

With Me.Consigned
.DefaultValue = IIf(.Value, "-1", "0")
End With
 
This didn't seem to work as I was intending... I was still getting the
default unchecked state when the previous box was checked...

I've also attempted to set the Checkbox's Checked property, with the
previous value with: Me!Consigned.Checked = Me!Consigned.Value
Also with no luck...

Any other suggestions?
 
If you want the check box to default to the opposite of its current state,
reverse the logic, i.e.:
With Me.Consigned
.DefaultValue = IIf(.Value, "0", "-1")
End With

The line:
Me!Consigned.Checked = Me!Consigned.Value
should fail with a message that the Checked property is not found.
 
Allen,

I don't want the opposite of the current state - I want what you gave me the
first time. However, with your code in there, it didn't do anyting
different. It just retained what the default value of the field was
regardless of the last data entered... I want for all new records to retain
the checkbox value of the last record entered. do you know how to do that?

Thanks so much for your help.
 
The code should work.

Perhaps we should clarify that Default Value is applied when Access goes to
a new record only.
 
So that I am communicating effectively, I will explain in an example what I
want to happen.

Steps:
I open this form and add the first record of the session. when I go to add
another record, I want all of the fields to 'autopopulate' the new record
with the same information that I entered on the previouse record. I have
that working on all of my fields (both text fields and integer fields) except
my True/False checkbox. The code you gave me didn't make it work either.
All of my other fields (integers) are as follows and it works.

Private Sub field_AfterUpdate()
'remembers last 'x' setting for new record
Me!field.DefaultValue = Me!field
End Sub

Does that clarify what I am doing, and help you help me? Thanks again.
 
Back
Top