Auto Populate fields from subform to form.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rotor
    New Member
    • Nov 2006
    • 72

    #16
    Okay, so I tried this:

    Code:
    Private Sub WO_WRI___s_Click()
        DoCmd.OpenForm "FormAcftJobsComp", acNormal, , , acFormAdd, acWindowNormal, "<WorkOrder/WRI>"
        
    End Sub
    
    Private Sub Form_Activate()
      Me![txtWO/WRI#'s] = Right(Me.OpenArgs, Len(Me.OpenArgs) - InStr(Me.OpenArgs, ","))
    End Sub
    It opens form, but the wo# is not autofilled, all I get is default value set by "FormsAcftJobsC omp".

    I believe I have all the code in the right spot, it seems it is now a matter of sorting out the code itself? The "WorkOrder/WRI" is the field in the form being opened, FormAcftJobsCom p", that I need populated with the information from field "WO/WRI#'s" the user clicked in the subform.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32668

      #17
      Rotor,

      It seems like you've made a whole heap of progress without any support. Congratulations and sorry for my absence. It's to be extended I'm afraid, at least until tomorrow as I've got to give this some careful thought and it's after 02:00 at the moment.
      If you hear nothing tomorrow then bump it. I don't want to leave you hanging.

      Cheers -NeoPa.

      Comment

      • Rotor
        New Member
        • Nov 2006
        • 72

        #18
        Originally posted by NeoPa
        Rotor,

        It seems like you've made a whole heap of progress without any support. Congratulations and sorry for my absence. It's to be extended I'm afraid, at least until tomorrow as I've got to give this some careful thought and it's after 02:00 at the moment.
        If you hear nothing tomorrow then bump it. I don't want to leave you hanging.

        Cheers -NeoPa.
        NeoPa, I appreciate all the help you all have given me for the past few weeks. I in no way expect immediate help, nor for you stay up into the wee hours of the morning on my account. Now, sleep well, and then work the next 48hrs straight until problem is solved ;). Just kidding. Again, thxs for your help.

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32668

          #19
          Right, lets start off by naming the from and to forms so we know where we are.
          Can you let me have the names of the form you're starting from (caller) and the form you're calling (callee).
          Some of the code goes in one and the other goes in the other so we need to be clear as to what we're saying here.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32668

            #20
            Originally posted by Rotor
            NeoPa, I appreciate all the help you all have given me for the past few weeks. I in no way expect immediate help, nor for you stay up into the wee hours of the morning on my account. Now, sleep well, and then work the next 48hrs straight until problem is solved ;). Just kidding. Again, thxs for your help.
            Lol.
            Missed this the first time around :D
            I can't say I was up just sorting you out Rotor, but I did remember that I'd made a mental note not to leave you blowing in the wind for too long.

            Comment

            • Rotor
              New Member
              • Nov 2006
              • 72

              #21
              Originally posted by NeoPa
              Right, lets start off by naming the from and to forms so we know where we are.
              Can you let me have the names of the form you're starting from (caller) and the form you're calling (callee).
              Some of the code goes in one and the other goes in the other so we need to be clear as to what we're saying here.
              Okay, subform "SubFormAcftWor ked" resides within "FormEntryP age" as a quick preview for my users of hull# and associated WO# recently worked. It displays the last 10 records from its correspoding table.

              By clicking field "WO/WRI#'s" form "FormAcftJobsCo mp" is opened where the user can enter a new job done. I would like for the field "WorkOrder/WRI" in form "FormAcftJobsCo mp" to be populated from the respective field "WO/WRI#'s" that the user clicked in subform "SubFormAcftWor ked".

              Clear as mud?

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32668

                #22
                Originally posted by Rotor
                Okay, subform "SubFormAcftWor ked" resides within "FormEntryP age" as a quick preview for my users of hull# and associated WO# recently worked. It displays the last 10 records from its correspoding table.

                By clicking field "WO/WRI#'s" form "FormAcftJobsCo mp" is opened where the user can enter a new job done. I would like for the field "WorkOrder/WRI" in form "FormAcftJobsCo mp" to be populated from the respective field "WO/WRI#'s" that the user clicked in subform "SubFormAcftWor ked".

                Clear as mud?
                Firstly, your naming is causing you (us) problems as you're using invalid characters which need to be replaced when creating procedures. This doesn't make life easier.

                Secondly, what type of field is [WO/WRI#s]? I've assumed an integer will hold the value but let me know if it's string or other type of field.

                Try, in your [SubFormAcftWork ed] module :
                Code:
                Private Sub WO_WRI___s_Click()
                    DoCmd.OpenForm "FormAcftJobsComp", acNormal, , , acFormAdd, acWindowNormal, Me.[WO/WRI#s]
                End Sub
                I suspect you're not copy/pasting as your field name seems to change between references, but it's whatever you have that is the correct spelling for it in code (Type Me.WO & see what appears).

                Now, in your [FormAcftJobsCom p] module :
                Code:
                Private intWOWRIs As Integer
                
                Private Sub Form_Open()
                  intWOWRIs = Me.OpenArgs
                End Sub
                Start with this. If this works, we can move forwards.

                Comment

                • Rotor
                  New Member
                  • Nov 2006
                  • 72

                  #23
                  Originally posted by NeoPa
                  Firstly, your naming is causing you (us) problems as you're using invalid characters which need to be replaced when creating procedures. This doesn't make life easier.
                  Okay, I am going to eliminate this variable by changing the field names, then I'll get back to ya with the rest. That way we know for sure that is not the problem.

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32668

                    #24
                    Sounds like a plan :)

                    Comment

                    • Rotor
                      New Member
                      • Nov 2006
                      • 72

                      #25
                      Okay, I renamed all pertinent fields to "WOorWRI"

                      Here is the code in the subform to open "FormAcftJobsCo mp":

                      Code:
                      Private Sub WOorWRI_Click()
                          DoCmd.OpenForm "FormAcftJobsComp", acNormal, , ,
                          acFormAdd, acWindowNormal, Me.[WOorWRI]
                      End Sub
                      Here is the code I placed in the form "FormAcftJobsCo mp":
                      Code:
                      Private intWOorWRI As Integer
                      Private Sub Form_Open()
                          intWOorWRI = Me.OpenArgs
                      End Sub
                      Okay, when the field is clicked i get a Run-time error '2501' The Open Form Action was cancelled. When I open the debugger the whole first code is highlighted.

                      Comment

                      • NeoPa
                        Recognized Expert Moderator MVP
                        • Oct 2006
                        • 32668

                        #26
                        What's highlighted exactly?
                        The code you have in WOorWRI_Click() cannot work as displayed, as there is no '_' at the end of the first line. Lines in VBA cannot be spanned without the continuation character (_).

                        Comment

                        • Rotor
                          New Member
                          • Nov 2006
                          • 72

                          #27
                          Code:
                          Private Sub WOorWRI_Click()
                              DoCmd.OpenForm "FormAcftJobsComp", acNormal, , ,
                              acFormAdd, acWindowNormal, Me.[WOorWRI]
                          End Sub
                          Originally posted by NeoPa
                          What's highlighted exactly?
                          The code you have in WOorWRI_Click() cannot work as displayed, as there is no '_' at the end of the first line. Lines in VBA cannot be spanned without the continuation character (_).
                          I am lost. I copy pasted the code you posted, I only changed the field name. The split in my post was just for posting purposes, in the editor the line is one continuous line. As such:

                          Code:
                          DoCmd.OpenForm "FormAcftJobsComp", acNormal, , , acFormAdd, acWindowNormal, Me.[WOorWRI]
                          In the debugger, the whole line as in the above window is highlighted.

                          Comment

                          • NeoPa
                            Recognized Expert Moderator MVP
                            • Oct 2006
                            • 32668

                            #28
                            That's fine Rotor. I had to check, even though I had considered it likely that what you said was the case.
                            I didn't know what you meant about the line that was highlighted though, so that's clarified nicely. I'll try to look into why when I get a break, as I'm at work atm.

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32668

                              #29
                              I've checked it over and can't see why it wouldn't work.
                              The code I posted was simply a doctored version of what you had before. Instead, try using :
                              Code:
                              DoCmd.OpenForm "FormAcftJobsComp", , , , , , Me.[WOorWRI]
                              (It's narrower too :D)
                              Let me know if this has problems too.

                              Comment

                              • Rotor
                                New Member
                                • Nov 2006
                                • 72

                                #30
                                Originally posted by NeoPa
                                I've checked it over and can't see why it wouldn't work.
                                The code I posted was simply a doctored version of what you had before. Instead, try using :
                                Code:
                                DoCmd.OpenForm "FormAcftJobsComp", , , , , , Me.[WOorWRI]
                                (It's narrower too :D)
                                Let me know if this has problems too.
                                Sorry, no dice NeoPa....the only thing I noticed between your code and the initial iteration I tried is the brackets and quotations around the field name?

                                Comment

                                Working...