Retaining last Checkbox value

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

Guest

I cannot find the answer to my problem. I have 7 fields on a form. 4 of
these fields are numeric, 2 are text and one is a checkbox (true/false). I
have all of these fields set up to automatically fill in the new record with
the same data that was entered in the last record that was completed. This
is working on all of my fields except the checkbox. What is different from
the checkbox? Below are samples of my code.

**This first sections works for the number fields
Private Sub shelf_AfterUpdate()
'copies last shelf location to new record
Me!Shelf.DefaultValue = Me!Shelf
End Sub

**This second section doesn't work for the checkbox
Private Sub consigned_AfterUpdate()
'remembers last consignment setting for new record
Me!Consigned.Checked = Me!Consigned.Value
End Sub

**This last section works for my text fields
Private Sub dateshipped_AfterUpdate()
'remembers last scout shipdate for new records
Me!DateShipped.DefaultValue = """" & Me!DateShipped & """"
End Sub

What am I doing wrong?
 
Why not assign the value to DefaultValue as you are with the others.
I tested it quickly and it seemed to work.

Me!Consigned.Defaultvalue = Me!Consigned
 
I am still stumped. I have tried every possible way I can think, including
the obvious that you have stated. How can I tell the code to think of this
checkbox as a numeric string/value like everything else - or how can I write
the code for the next record to remember the checkbox... this should be easy.

here is the code I have now that IS NOT working. any suggestions. thanks!

Private Sub consigned_AfterUpdate()
'remembers last consignment setting for new record
Me!Consigned.DefaultValue = Me.Consigned
End Sub
 
I created a table autonumber, firstName, LastName, Check.
Created a form bound to the table and added 2 text and Check box all bound
to the fields above. In Surname and check I placed the afterupdate code
below. The 1st ,3rd,5th entry I put new data. The 2nd,4th etc I just changed
the first name. As the table below shows it picked up the defaults OK. Is the
check box part of a Action Group? If it is you should deal with the group
frame. Is at least 1 new entry being made before the form updates? Access
will not update unless an entry is made. If you have troubles try to
duplicate the above and then work up from there. I hope this helps.
Table
ID FirstName SurName Check
14 John Smith True
15 Brian Smith True
16 Allan Jones False
17 Anne Jones False
18 Gwynne Roberts True
19 Jack Roberts True

Private Sub Check_AfterUpdate()
Me.check.DefaultValue = Me.check
End Sub

Private Sub SurName_AfterUpdate()
Me.SurName.DefaultValue = """" & Me.SurName & """"
End Sub
 
Default values must be stored as strings, even if the value it represents is
numeric or, as in this case, boolean.

Try:

Private Sub consigned_AfterUpdate()
'remembers last consignment setting for new record
Me!Consigned.DefaultValue = Chr$(34) & Me.Consigned & Chr$(34)
End Sub
 
Back
Top