Form that updates another form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mtrcct
    New Member
    • Feb 2007
    • 19

    Form that updates another form

    Hi, I have been playing around with various forms and have asked some previous questions on this topic, but thought it best to start a new thread since my forms structes have changed if anyone can help I am almost there.

    I have two forms
    Form 1 =Detail
    Form 2 =DetailUpdate (the fields in this form are bound to a table OrderDetailUpda te)

    Detail displays information based on a combo box look up in a datasheet view from a table OrderDetail, the look up value is OrderNumber. I have a command button that opens the form in DetailUpdate , also a datasheet view and I want the data from Detail that is displayed to carry over to DetailUpdate. Form 1 has fields OrderNumber and PartNumber and I put code in the command button to put those fields into Form 2, this works but it only populates the first row and most times Form 1 has multiple lines on it. I was thinking if there was a way to instruct the code to append the data of all records from Form 1 to 2.


    This is what I have right now:
    ////////////////////////////////////////////////////////////////////////////////////////
    Code:
    Private Sub OpenOrderUpdateForm_Click()
    On Error GoTo Err_OpenOrderUpdateForm_Click
    
        Dim stDocName As String
        Dim stLinkCriteria As String
    
        stDocName = "frmDetailUpdate"
        
           DoCmd.OpenForm stDocName
        Forms!frmDetailUpdate!OrderNumber = Me.OrderNumber
        Forms!frmDetailUpdate!PartNumber = Me.PartNumber
    Exit_OpenOrderUpdateForm_Click:
        Exit Sub
    
    Err_OpenOrderUpdateForm_Click:
        MsgBox Err.Description
        Resume Exit_OpenOrderUpdateForm_Click
        
    End Sub
    /////////////////////////////////////////////////////////////////////////////////////////////
    This updates the first line, but that is all. Might be a simple answer, but I sure can't figure it out. Any help would be appreciated.

    Thanks Mark.
    Last edited by NeoPa; Mar 15 '07, 03:20 PM. Reason: Tags
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32645

    #2
    Mark,
    This is another example of where people will find it difficult to help. Your explanation makes it hard to understand what you're after. When you talk about sending something to another form, that's hard to understand as forms don't really store anything at all. They simply show data from a table or a query. Perhaps you could try to redo the question (in this thread) paying particular attention to making it clear what you're after.

    Comment

    • mtrcct
      New Member
      • Feb 2007
      • 19

      #3
      Neo, I understand what you are saying and let me try to re-phrase.

      I am building a purchasing database that the user enters requisition information in a table DetailHeader and Detail all from one form that I built and that works fine.

      Now I am trying to build a form that takes the previously entered information from the Detail table and add the addtional purchase order information to each line so the user does not have to enter the information a second time.

      I have a combo box that fills the form Detail when the user selects a requision number from table Detail and I want to take this information and move it to another form that is bound to the table DetailUpdate.

      The code I posted above opens the form DetailUpdate via a command button and works for just one line, but does not increment the rows to match the results displayed that are currently displayed in the Detail form. Basically, I am trying to clone the form Detail but make it bound to another table.

      I understand that a form displays data from a table, but was thinking if I could throw that result to another form it would make the data entry so much easier.

      Thanks for the feedback and I hope this makes more sense.

      Mark.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32645

        #4
        I'm sorry Mark.
        This makes little more sense to me. I can't give you an answer to this question.
        I can't even tell you how you should write the question as I can't tell what you want. I don't mean to criticise so I'll just step back and leave you to decide how best to play it from here.

        Comment

        • mtrcct
          New Member
          • Feb 2007
          • 19

          #5
          Neo, no offense taken.
          I need to put this english so as not to waste any more of the experts time here. Thanks for your support, the forum is great. I am learning a lot just from reading responsed to questions that others have posted.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32645

            #6
            I'm pleased you feel that way Mark.
            I'll catch anything else you post here now so I'll see what I can do if you repost :)

            Comment

            • Denburt
              Recognized Expert Top Contributor
              • Mar 2007
              • 1356

              #7
              Hmmm let see if this will help you.


              Code:
              Private Sub OpenOrderUpdateForm_Click()
              On Error GoTo Err_OpenOrderUpdateForm_Click
              
                  Dim stDocName As String
                  Dim stLinkCriteria As String
              Dim db as database
                  Dim rs as recordset
                  Dim rs1 as recordset
              
                  stDocName = "frmDetailUpdate"
                  
                     DoCmd.OpenForm stDocName
              set db = currentdb
              set rs = me.recordsetclone
              set rs1 = db.openrecordset("OrderUpdate")
              If not rs.eof then 
              Do until rs.eof
              rs1.edit
              rs1.addnew
              
                  rs1!OrderNumber = Me!OrderNumber
                  rs1!PartNumber = Me!PartNumber
              
              rs1.update
              loop
              end if
              rs1.close
              rs.close
              set rs1 = nothing
              set rs = nothing
              set db = nothing
              Exit_OpenOrderUpdateForm_Click:
                  Exit Sub
              
              Err_OpenOrderUpdateForm_Click:
                  MsgBox Err.Description
                  Resume Exit_OpenOrderUpdateForm_Click
                  
              End Sub
              Typing off the cuff here so I hope I didn't I miss anything.

              Comment

              • mtrcct
                New Member
                • Feb 2007
                • 19

                #8
                Denburt, thanks for the info! I'll give it a try and let you know....

                Mark.

                Comment

                Working...