Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21

    Using last value in a new record field

    Hi all,

    I have a database that I would like just the one field to remember it's last entry and place that value in the same field in a new record.....

    e.g

    If you type house in a field, when you go to a new record, that same field must show house again..... If I then change house to cottage, the next new record will show cottage......

    Hope I am clear enough with my description?

    Thanks for all help.... I am using Access 2000



    Peter

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21
    Hi Paul,
    Thanks for this reply..... I do not think this is the same thing as I am looking for.... On my form I have a a group of fields..... in the one field named "Type" I will say type in "House"... I finish that record and press the button for new record..... In the "Type" field of the new record, I would like to see house in there automatically..... If I wish to change it to cottage, then I can just retype that field to cottage.... then in the next new record it will show cottage..... Am I clearer? I hope so.... a bit confusing.....

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I think that's what you're after, though I would put it in the after update event of the textbox on the form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21
    Hi Paul,
    I did as you said.... but it did not work.... Umm not sure what is happening.... It came up with an error that it did not recognize "Control".... Strange..... coding is not a strong thing of mine hahahahha

    Peter

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    "Control" needs to be replaced by the name of your control (presumably a textbox).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21
    Thanks Paul....

    This is my code:

    Private Sub Text34_AfterUpdate()
    Const cQuote = """" 'Thats two quotes
    Me!Text34.DefaultValue = cQuote & Me!Text34.Value & cQuote
    End Sub

    When I type into the textbox and save then insert new record... nothing is showing.....

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Can you post the db here?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21
    Hi Paul,

    Do you have a email address I can send the base to? I do not wish to post it to the forum as this will in the end be a paid for base..... But I can post the code to the problem as and when I sort it out..... Sorry....

    Peter

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You can send to

    removed
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21
    Hi Paul,
    I have sent you the database.... I would delete the last post you sent me to stop people abusing your email.....

    Thanks
    Peter

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I'm not sure what isn't working for you. If I enter something in that textbox and then on the new record button at the bottom, that field has what I typed in the previous record ready to go for the next. You're not closing the form, are you? This technique won't survive the form closing. To do that you'd have to save the value somewhere, either in a public variable or table, or change the default value property at the table level.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    Pgill is offline Novice
    Windows XP Access 2000
    Join Date
    Jul 2011
    Posts
    21
    Hi Paul, sorry about the delay in things.... It was midnight when I sent the database, then this morning I had to go out..... You may be right about closing the form and losing the choice.... How would I go about saving the answer into a table and calling it back up at a later opening? Umm, unless I do a list box and a button to add another detector, that will become the default..... What did you think about the database and what I have done so far?

  14. #14
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I'd like to point something out, you do NOT want to populate the next record with ANY value before you are ready to append the record to your table otherwise you'll end up with a bunch of records with no data.

    What I would suggest is that when you do your data entry you hit the ctrl ' key it will copy the value from the previous record into the current record or at the very worst once you have enough data (all your required elements are there) you can perform a dlookup function in the ON EXIT property of one of your data entry fields to populate the house type before you get to it.

  15. #15
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Rpeare, we've been discussing setting a default value, not populating a record.

    Pgill, I've never tried to do that. I suppose you could save the value to a single record table and put a DLookup() in the default value property of the textbox.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-25-2011, 12:22 PM
  2. Populate field from field on previous record
    By randolphoralph in forum Forms
    Replies: 7
    Last Post: 03-04-2011, 11:28 AM
  3. Bolding a record in a field that is the max
    By salisbut in forum Access
    Replies: 3
    Last Post: 08-17-2010, 09:57 AM
  4. Allow change to a field on new record only
    By Grooz13 in forum Forms
    Replies: 4
    Last Post: 08-16-2010, 11:36 AM
  5. Replies: 1
    Last Post: 02-26-2009, 11:31 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums