How can I get Access to remember a digit or a character?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wassimdaccache
    New Member
    • Apr 2007
    • 222

    How can I get Access to remember a digit or a character?

    Hello everybody;

    How may I write a function on MS access to carry a digit and use it in my forms.?


    For example a continuous form contains sceneID as primary key and scene descreption (refer to scene table)

    When user double click on the sceneID I want a function to memories this ID for later use (as buffer) even the form will be closed.


    Please advise me.

    WASSIM S DACCACHE
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    You could use a code module and put a global variable in there.
    When you double click you set the variable equal to what you want memorized.
    Now you just reference the global variable when you want to use the value that was memorized.

    Comment

    • wassimdaccache
      New Member
      • Apr 2007
      • 222

      #3
      Originally posted by Delerna
      You could use a code module and put a global variable in there.
      When you double click you set the variable equal to what you want memorized.
      Now you just reference the global variable when you want to use the value that was memorized.
      Could you please provide me the syntax and the method to write a global function.

      Any link about this subject might help me.


      Appreciate your help.

      Take care;


      WASSIM S DACCACHE

      Comment

      • Delerna
        Recognized Expert Top Contributor
        • Jan 2008
        • 1134

        #4
        1) open access
        2) goto modules tab and click new
        3) In code widow on a new line type
        [code=vb]
        Public NameOfYourVaria ble as int
        [/code]
        4) save the module and call it "PublicStuf f" or something like that

        Ok thats your global variable created.
        Now in the code page for the form you want the double click to memorize.

        [code=vb]
        Private sub txtSceneID_DblC lick(Cancel As Integer)
        NameOfYourVaria ble=txtSceneID
        End sub
        [/code]
        txtSceneID is the name of the control on the form that you want to add the double click functionality to

        Ok now the SceneID has been saved into NameOfYourVaria ble and you can get its value from anywhere. That will remain true until the database is closed.


        so for example, in the code page for another form you could do this.
        [code=vb]
        Private Sub Form_Load()
        txtNameOfATextb oxControlOnTheF orm = NameOfYourVaria ble
        End Sub
        [/code]


        Does that help?

        Comment

        • wassimdaccache
          New Member
          • Apr 2007
          • 222

          #5
          Originally posted by Delerna
          1) open access
          2) goto modules tab and click new
          3) In code widow on a new line type
          [code=vb]
          Public NameOfYourVaria ble as int
          [/code]
          4) save the module and call it "PublicStuf f" or something like that

          Ok thats your global variable created.
          Now in the code page for the form you want the double click to memorize.

          [code=vb]
          Private sub txtSceneID_DblC lick(Cancel As Integer)
          NameOfYourVaria ble=txtSceneID
          End sub
          [/code]
          txtSceneID is the name of the control on the form that you want to add the double click functionality to

          Ok now the SceneID has been saved into NameOfYourVaria ble and you can get its value from anywhere. That will remain true until the database is closed.


          so for example, in the code page for another form you could do this.
          [code=vb]
          Private Sub Form_Load()
          txtNameOfATextb oxControlOnTheF orm = NameOfYourVaria ble
          End Sub
          [/code]


          Does that help?
          Yeah it is working well. Appreciate your help again






          WASSIM S DACCACHE

          Comment

          • ADezii
            Recognized Expert Expert
            • Apr 2006
            • 8834

            #6
            Originally posted by wassimdaccache
            Could you please provide me the syntax and the method to write a global function.

            Any link about this subject might help me.


            Appreciate your help.

            Take care;


            WASSIM S DACCACHE
            Be advised that assigning a value to a Global Variable will not retain that value once the Form is closed. You seem to indicate that this was your intention. In this case I would normally write the value to an Internal, Hidden Table or store it in the System Registry (my favorite).

            Comment

            • wassimdaccache
              New Member
              • Apr 2007
              • 222

              #7
              Dear Sir,


              You are right I oblige user to don;t close the form meanwhile I did what I was looking for.

              Now it is for my curiosity ;). If I want to close the form that is carrying the value and I don't want to save it in a form because I am sharing my database on my network and I assign for every user a file that contain forms (Link database) .

              How may I do it using the registry? Do I have a limited size in the registry ?

              Could you send me any link about this subject it might be useful...

              Thank you in advanced

              Take care

              WASSIM S DACCACHE

              Comment

              • ADezii
                Recognized Expert Expert
                • Apr 2006
                • 8834

                #8
                Originally posted by wassimdaccache
                Dear Sir,


                You are right I oblige user to don;t close the form meanwhile I did what I was looking for.

                Now it is for my curiosity ;). If I want to close the form that is carrying the value and I don't want to save it in a form because I am sharing my database on my network and I assign for every user a file that contain forms (Link database) .

                How may I do it using the registry? Do I have a limited size in the registry ?

                Could you send me any link about this subject it might be useful...

                Thank you in advanced

                Take care

                WASSIM S DACCACHE
                Youo can reference the SaveSetting Statement and GetSetting() Functions in the Access Help Files for an explanation and demo.

                Comment

                • Delerna
                  Recognized Expert Top Contributor
                  • Jan 2008
                  • 1134

                  #9
                  Sorry, but I tried it out when i was developing the solution and if you put the global variable into a code module then you most certainly can retain and access its contents without the need of any form being left open.

                  If you put the global variable into the forms code page then yes you must have that form open. But if you put it in a code module then it remains active until you close the database.

                  Comment

                  • ADezii
                    Recognized Expert Expert
                    • Apr 2006
                    • 8834

                    #10
                    Originally posted by Delerna
                    Sorry, but I tried it out when i was developing the solution and if you put the global variable into a code module then you most certainly can retain and access its contents without the need of any form being left open.

                    If you put the global variable into the forms code page then yes you must have that form open. But if you put it in a code module then it remains active until you close the database.
                    Thanks for the clarification Delerna. You are, of course, correct and I apologize for the confusion.

                    Comment

                    • NeoPa
                      Recognized Expert Moderator MVP
                      • Oct 2006
                      • 32668

                      #11
                      Originally posted by wassimdaccache
                      ...
                      You are right I oblige user to don;t close the form meanwhile I did what I was looking for.
                      Wassim, You do understand that this is no longer required now don't you? The value will persist for as long as the project code is active (Unless the project is stopped due to a design change in the database or the database is closed).

                      Comment

                      • wassimdaccache
                        New Member
                        • Apr 2007
                        • 222

                        #12
                        Originally posted by NeoPa
                        Wassim, You do understand that this is no longer required now don't you? The value will persist for as long as the project code is active (Unless the project is stopped due to a design change in the database or the database is closed).
                        Yes sir I do understand but actually still have a problem my file is shared into 12 computers and each one contains its specific form what I need is to use the file shared (contains the table) function. In another meaning I need the function to carry me the digit or string for all forms linked to the file shared.

                        How May I call a function from another database ?


                        please give me your opinion.

                        Best regards,


                        WASSIM S DACCACHE

                        Comment

                        • NeoPa
                          Recognized Expert Moderator MVP
                          • Oct 2006
                          • 32668

                          #13
                          Wassim, I'm afraid I have very little idea what you're trying to say :S

                          I would think that the answer previously given is what you need, but I'm not sure because I don't know what you're asking now.

                          Comment

                          • wassimdaccache
                            New Member
                            • Apr 2007
                            • 222

                            #14
                            Originally posted by NeoPa
                            Wassim, I'm afraid I have very little idea what you're trying to say :S

                            I would think that the answer previously given is what you need, but I'm not sure because I don't know what you're asking now.
                            Dear neo,

                            I'll try to be more clear in my question.

                            what Mr. Delerna told me about the public function it works even when I close the file.

                            Now it is another subject under the same title.

                            The idea is to split my file into tables(file1) and forms(file2)
                            file2 is linked table on file1

                            the problem that I am facing is:
                            when I call the function in file 2 it is not working. the function is just working locally.

                            How may use the function from the file1 ?


                            I would like to advise me.

                            Best regards

                            Comment

                            • NeoPa
                              Recognized Expert Moderator MVP
                              • Oct 2006
                              • 32668

                              #15
                              I think I understand better now Wassim.

                              I'm not sure exactly how you've organised your two database, but when organised in the usual FrontEnd/BackEnd (FE/BE) way, there should be no such problems. Check out Front-End / Back-End (FE/BE) for more on this subject.

                              PS. I should point out that new questions should really be put in separate threads. There are various reasons for this, one of which is that it will tend to mean that your new question is not seen as such, and may get overlooked by many of our experts (You appreciate that they're not looking for answered questions). Another is that responses will be less clear as it is possible for other posters to add posts related to the original question. This can only lead to confusion.
                              Please post your questions in their own threads in future (See How to Ask a Question).

                              Comment

                              Working...