update multiple records

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • garymilam
    New Member
    • May 2016
    • 24

    update multiple records

    I have a date closed field on a form. How do I make this field update multiple records. For example. I have books database. I have multiple books checked out with a date. I want to update the checkout date from my checkout form on multiple records which is a continuous form. Please help
  • garymilam
    New Member
    • May 2016
    • 24

    #2
    update multiple records

    I have attached my DB. I need to update all the records that have been selected for checkout with the checkout date from above. Somebody please help, I need this for my job. Thanks.
    Attached Files

    Comment

    • PhilOfWalton
      Recognized Expert Top Contributor
      • Mar 2016
      • 1430

      #3
      Firstly, I think your FPrint field should be a Y/N field, not a text box. This would change the form to having a check box.
      So you would select the books that you want to apply the checkout date to by "ticking" the check box.
      Secondly you need a Command Button on your form that would then run the routine to update the records with the checkout date.

      Questions:

      What do you want to do if there is already a checkout date against a book?

      How many books are there: is the list going to be impossibly long?

      Phil

      Comment

      • jforbes
        Recognized Expert Top Contributor
        • Aug 2014
        • 1107

        #4
        There are a few different ways to go about this.

        One is to use a RecordSetClone of your Form and iterate through all the records, and update the Date. Here is an example that updates an Integer field:
        Code:
            Dim oRst As DAO.Recordset
            Dim iCount As Integer
            
            iCount = 0
            Set oRst = Me.RecordsetClone
            oRst.MoveLast
            oRst.MoveFirst
            Do While Not oRst.EOF
                iCount = iCount + 1
                oRst.Edit
                    oRst!PrintIndex = iCount
                oRst.update
                oRst.MoveNext
            Loop

        Another is to build up a SQL Update Statement in VBA and then call CurrentDB.Execu te:
        Code:
            Dim sSQL As String
            If Len(Me.Filter) > 0 Then
                sSQL = ""
                sSQL = sSQL & "UPDATE Drawings SET LastModifiedDate=#" & Now() & "# "
                sSQL = sSQL & "WHERE " & Me.Filter
                CurrentDB.Execute sSQL
            End If

        Comment

        • garymilam
          New Member
          • May 2016
          • 24

          #5
          Basically the check out date in my real dB is a destruction date. I would ultimately like to have that record archived somehow once there is a destruction date. as far as records, eventually there will be anywhere from 0-200 give or take. I really appreciate the help, I'm still kind of a novice at this, and can use all the help I can take. I really enjoy designing databases and want to learn all I can.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32645

            #6
            I've merged these two threads as we forbid double-posting of questions here.

            Unfortunately, neither attempt seems to be well enough expressed to make good sense on its own. Hopefully together they do.

            @Gary.
            It's your responsibility to ensure your questions are clearly laid out when you post your question originally. If, as you say, it's important for your job, then it's particularly important for you. Poor and lazy questions are far less likely to get sensible answers as the experts will struggle to match the answer to the question.

            Comment

            Working...