Results 1 to 11 of 11
  1. #1
    Join Date
    May 2009
    Posts
    4

    Unanswered: Use last record to fill out form

    I'm filling in years of timecard data, into access (2003 mdb format on 2007), for the date and who fields, I would like the new record to autofill those two feilds with the last value. Any ideas how.

    Each record is a specific charge, so there are many days of data for the same person and week ending date. Just trying to make the data entry easier.
    Thanks!

  2. #2
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    Is the existing data on paper?

    If not there is probably a way to import it.
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  3. #3
    Join Date
    May 2009
    Posts
    4

    Yep, on paper

    Yes, I'm entering three year old timecards... from paper

  4. #4
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    Are you able to post a .zip of your database?

    There are various ways you can achieve this...
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  5. #5
    Join Date
    May 2009
    Posts
    4
    Its considered proprietary...
    Can you advise me. It is just a thrown together quicky of 4 tables (employee, cost codes, and project info in other tables, hours and date on the Hours table.
    If needed I can remove the proprietary info...Let me know and thanks

  6. #6
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    Hang fire, I will knock an example up...
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  7. #7
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580

    Question Method 1

    Use public variables to store the 'last-entered' data - sure others can suggest alternatives...

    Code behind form is as follows
    -----------------------------------------------------
    Option Compare Database
    'Public variables to store 'last' values
    Public varDate1 As Date
    Public varDate2 As Date


    Private Sub datDate1_AfterUpdate()

    'Set the date1 variable to whatever has just been entered into the control
    varDate1 = Nz(Me.datDate1, "")

    End Sub

    Private Sub datDate2_BeforeUpdate(Cancel As Integer)

    'Set the date2 variable to whatever has just been entered into the control
    varDate2 = Nz(Me.datDate2, "")

    End Sub

    Private Sub Form_Current()

    'Set the controls to the value of the public variables
    Me.datDate1 = Nz(varDate1, "")
    Me.datDate2 = Nz(varDate2, "")

    End Sub

    Private Sub Form_Open(Cancel As Integer)

    'Give a value to the public variables
    varDate1 = Now()
    varDate2 = Now()

    End Sub
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  8. #8
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    datDate1 and datDate2 are the names of the contols on the form - I am dashing out and don't have time to post .zip (this machine playing up!) hope you get it sorted.
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

  9. #9
    Join Date
    May 2009
    Posts
    4
    Yes, I think that will do it, but I gotta leave for a short time too. Will let you know.

  10. #10
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    In your form, you can use the AfterUpdate event of the control holding your data to set the DefaultValue for the field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each new record.

    This should do it for your fields:

    Code:
    Private Sub datDate1_AfterUpdate()
     datDate1.DefaultValue = """" & Me.datDate1 & """"
    End Sub
    Code:
    Private Sub datDate2_AfterUpdate()
      datDate2.DefaultValue = """" & Me.datDate2 & """"
    End Sub
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  11. #11
    Join Date
    Sep 2002
    Location
    South Wales
    Posts
    580
    Def. better solution from Missingling...

    If there is any pattern to the data though (say it's MAINY consistent - range of dates, same person, mostly working same hours) another approach might be to create the records, browse through and kind of 'configure' using your forms.

    Depends really on how many records you have and whether the above is true.

    Let us know whether this is worth persuing.
    Windows Server 2003-8 / Terminal Services / SQL 2000 / Access 2003 / Office 2003-7 / Exchange 2003-7 / Blackberry Enterprise Server / AutoCAD / Lambert And Butler / Red Bull

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •