Access 2000 - Carry a number through to another form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jacc14
    New Member
    • Jun 2007
    • 116

    Access 2000 - Carry a number through to another form

    All

    I am using Access 2000

    I have created a list of records. When I double click the job number field it opens a new form.

    The code i use is this.

    Code:
    Dim stDocName As String
    Dim stLinkCriteria As String
    
    stDocName = "frm_adjust_magazine_overs"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    I then retype that job number into the job number field on that new form and enter some figures.

    Ideally what I would like to do is to double click on the job number and that same number copy into the newly opened form so I can then add my figures.

    Thanks
    Jacc14
  • Krandor
    New Member
    • Aug 2008
    • 50

    #2
    Very simple.

    Create a new module.

    enter the following:
    Option Compare Database
    Option Explicit

    Public gn_YourNumber as double 'this is a global variable

    Now go to the first form. Now make gn_YourNumber equal to the number you are trying to pass.

    Now on the second form, you load the text box with your global variable in form load sub.

    That's all there is.


    Ramon

    Comment

    • jacc14
      New Member
      • Jun 2007
      • 116

      #3
      Hi Ramon

      Thanks for the advice, and so prompt. I have created the module but unfortunately am not an expert on this so not sure how to do the next bits.

      "Now go to the first form. Now make gn_YourNumber equal to the number you are trying to pass.

      Now on the second form, you load the text box with your global variable in form load sub."


      On the second form I have put the following.

      Code:
      Private Sub Form_Load()
      Me.OrderNo.Value = gn_Number
      End Sub

      Hope you can help

      Thanks
      Jacc14

      Comment

      • hjozinovic
        New Member
        • Oct 2007
        • 167

        #4
        On your First form go to OnDouble_click event of the JobNumber control.
        Put in a code like:
        Code:
        gn_YourNumber = Me!JobNumber
        ..and keep in place the rest of your original code that is allready there :-)

        Comment

        • mshmyob
          Recognized Expert Contributor
          • Jan 2008
          • 903

          #5
          I personally would just use the OpenArgs parameter when you do your Docmd.openform.

          Then in the Open event of the second form that you open you pick up the passed argument.

          No need for modules.

          cheers,

          Comment

          • mshmyob
            Recognized Expert Contributor
            • Jan 2008
            • 903

            #6
            As an ammendment if it is a true number field use the CStr and Val function.

            Comment

            • NeoPa
              Recognized Expert Moderator MVP
              • Oct 2006
              • 32634

              #7
              Are you clear on that now Jacc?

              If not I'm sure we can answer any questions you still have.

              Comment

              • jacc14
                New Member
                • Jun 2007
                • 116

                #8
                thanks for this.

                Just got back from a 2 week break so will have another go.

                Cheers
                jacc14

                Comment

                • jacc14
                  New Member
                  • Jun 2007
                  • 116

                  #9
                  Hi

                  Thanks all for your help. RESULT :)

                  Best regards

                  Jacc14

                  Comment

                  • NeoPa
                    Recognized Expert Moderator MVP
                    • Oct 2006
                    • 32634

                    #10
                    Good to hear that helped :)

                    Comment

                    Working...