Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Previous Record? (A2K)

    Haven't badgered you folks in a long time, so here goes:

    Scenario: ( aka Death by DOS )

    Master table has 4 fields ( there are really 185, but for the sake of simiplicity
    Cheers,
    Andy

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Previous Record? (A2K)

    A simple solution would be to create a query that selects the records for the current UserID. The user can then use <code>Ctrl+'</code> (apostrophe) to copy a value from the same field in the previous record - which will be a record from that same user.

    If that is not feasible, and/or if you want to retrieve values from the user's previous record in code, you can use DLookup in combination with DMax:

    DLookup("FieldName", "TableName", "SRT_CN = " & DMax("SRT_CN", "TableName", "UserID = " & Me.UserID & " And SRT_CN < " & Me.SRT_CN))

    The DMax expression retrieves the highest SRT_CN for this user lower than the SRT_CN of the current record, and DLookup fetches the specified field from the record with this SRT_CN.

    (You must, of course, substitute the appropriate names)

  3. #3
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previous Record? (A2K)

    Hans,

    You never fail to amaze! I shall now take your answer(s) and go and play with them. I'll get back to you and let you know how I've fared,

    Thanks again,
    Cheers,
    Andy

  4. #4
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previous Record? (A2K)

    Hans,

    Sorry about the delay in the following up of my own problem. Got sidetracked by forces beyond my control.

    Now, the code for the 2nd solution you prescribed visually appears to look like the perfect answer. I
    Cheers,
    Andy

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Previous Record? (A2K)

    I thought you wanted to copy some values from the previous record, but now you want the user to be able to "bring up her previous record". What exactly do you mean by that? Please try to be specific.

  6. #6
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previous Record? (A2K)

    Hans,

    Sorry about that. Long weekend. Yes, you are correct, I was unspecific. My train of thought was totally derailed.

    To reiterate:

    The User of a specific UserId is entering records along with other users.

    And, yes, it is that User's previous record that needs duping.

    I hope that demuddies the water and clarifies my request a bit,
    Cheers,
    Andy

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Previous Record? (A2K)

    The entire record?

  8. #8
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previous Record? (A2K)

    Hans,

    Yes, the entire record, because, and I'm not trying to be cute here, they want some of the fields some of the time, but not all of the fields all of the time.
    Cheers,
    Andy

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Previous Record? (A2K)

    I'm confused again. "Yes, the entire record" and "but not all of the fields all of the time" seem to contradict each other.

  10. #10
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previous Record? (A2K)

    Hans,

    If at first I don't succeed....

    The user wants to have available her complete Previous record that she created.

    She will duplicate some of the fields and also replace some of the previous data with new data.

    As a for instance, 10 hard drives in a row with only the serial number changing. So, she wants all the descriptions and stuff from HER previous record, but only want to have to change the serial number and not reenter everything else.

    I think I'm going to go and take an anti-senility pill,
    Cheers,
    Andy

  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Previous Record? (A2K)

    You could place a command button cmdDuplicate with caption "Duplicate Record" on the form. The On Click event procedure for the button could look like this:

    Private Sub cmdDuplicate_Click()
    On Error GoTo ErrHandler
    If IsNull(Me.SRT_CN) Then
    Beep
    Exit Sub
    End If
    RunCommand acCmdSelectRecord
    RunCommand acCmdCopy
    RunCommand acCmdPasteAppend
    Exit Sub
    ErrHandler:
    If Not Err = 2501 Then
    MsgBox Err.Description, vbExclamation
    End If
    End Sub

    When the user clicks the button, the current record will be duplicated, the user can then modify some or all fields, as needed.

  12. #12
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previous Record? (A2K)

    Hans,

    Thanks again.

    I
    Cheers,
    Andy

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Previous Record? (A2K)

    The code I posted will duplicate the current record, and automatically assign a new AutoNumber. Just try it.

  14. #14
    5 Star Lounger
    Join Date
    Nov 2001
    Location
    Toronto Canada
    Posts
    920
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Previous Record? (A2K)

    Hans,

    If you have a moment, I'd appreciate your having a look at the attached Word document. Hopefully it will clarify things a bit,
    Cheers,
    Andy

  15. #15
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Previous Record? (A2K)

    I have proposed two simple, user-friendly and effective solutions. Since you have rejected both of them, I have tried to come up with a complicated solution that is guaranteed to cause RSI.
    In the form in the attached database, the user can press Ctrl+Alt+Shift+F12 in the F01_Part_No or F01_Part_Dscn text box to copy the value from the same field in the previous record by the same user.

Page 1 of 3 123 LastLast

Posting Permissions

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