By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,491 Members | 858 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,491 IT Pros & Developers. It's quick & easy.

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

100+
P: 222
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
May 2 '08 #1
Share this Question
Share on Google+
22 Replies


Delerna
Expert 100+
P: 1,134
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.
May 3 '08 #2

100+
P: 222
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
May 3 '08 #3

Delerna
Expert 100+
P: 1,134
1) open access
2) goto modules tab and click new
3) In code widow on a new line type
Expand|Select|Wrap|Line Numbers
  1. Public NameOfYourVariable as int
  2.  
4) save the module and call it "PublicStuff" 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.

Expand|Select|Wrap|Line Numbers
  1. Private sub txtSceneID_DblClick(Cancel As Integer)
  2.    NameOfYourVariable=txtSceneID
  3. End sub
  4.  
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 NameOfYourVariable 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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.    txtNameOfATextboxControlOnTheForm = NameOfYourVariable
  3. End Sub
  4.  

Does that help?
May 3 '08 #4

100+
P: 222
1) open access
2) goto modules tab and click new
3) In code widow on a new line type
Expand|Select|Wrap|Line Numbers
  1. Public NameOfYourVariable as int
  2.  
4) save the module and call it "PublicStuff" 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.

Expand|Select|Wrap|Line Numbers
  1. Private sub txtSceneID_DblClick(Cancel As Integer)
  2.    NameOfYourVariable=txtSceneID
  3. End sub
  4.  
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 NameOfYourVariable 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.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.    txtNameOfATextboxControlOnTheForm = NameOfYourVariable
  3. End Sub
  4.  

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






WASSIM S DACCACHE
May 3 '08 #5

ADezii
Expert 5K+
P: 8,597
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).
May 3 '08 #6

100+
P: 222
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
May 3 '08 #7

ADezii
Expert 5K+
P: 8,597
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.
May 4 '08 #8

Delerna
Expert 100+
P: 1,134
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.
May 4 '08 #9

ADezii
Expert 5K+
P: 8,597
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.
May 4 '08 #10

NeoPa
Expert Mod 15k+
P: 31,186
...
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).
May 5 '08 #11

100+
P: 222
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
May 6 '08 #12

NeoPa
Expert Mod 15k+
P: 31,186
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.
May 6 '08 #13

100+
P: 222
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
May 6 '08 #14

NeoPa
Expert Mod 15k+
P: 31,186
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).
May 6 '08 #15

Delerna
Expert 100+
P: 1,134
Hi wassim.
In the scenario you have presented, I think the better option would be as NeoPa suggests. One backend db with all the tables and data and as many copies of a front end that are linked to the tables in the backend and have all the reports, queries forms etc.
I think that is what you are describing anyway.

Anyway, instead of having a public variable in the front ends, you could have a table in the backend and save the ID into that table instead. That way all frontends would have access to the same table and therefore the same ID.
I have given an idea here, you will need to develop it to suit your needs
May 6 '08 #16

NeoPa
Expert Mod 15k+
P: 31,186
It seems I didn't understand the question as clearly as I thought I had :/
  1. If you want a value to persist within a particular user's session, then a global variable is a good way to do it. This would be in the FE database.
  2. If you want a value to persist, and be shared by various operators, then storing it in a table in the BE database would be a good way to handle this.
  3. If you want a value to persist and be available to the same operator, but from any of the FE databases, then storing (tagged) it in a table in the BE database would be a good way to handle this. This would involve storing an operator identifier with the data in the table. Clearly you'd need a method of identifying operators for this approach.
May 7 '08 #17

100+
P: 222
Hi Sirs,

I would like to appreciate your feedbacks about my post.

I apologize for not being clear from the beginning due to my problem process (locally and shared).

I think the best way is to save my record in a temporary table and use this value in as you advise.


Thank you again.

Best regards;
May 9 '08 #18

NeoPa
Expert Mod 15k+
P: 31,186
Wassim, I see no benefit in saving the value in a temporary table.

As a matter of interest, which of scenarios A, B or C most closely fits yours (See post #17)?
May 9 '08 #19

100+
P: 222
Wassim, I see no benefit in saving the value in an temporary table.

As a matter of interest, which of scenarios A, B or C most closely fits yours?
Dear Neo;

I think choice B is most closely to my IDEA.

Could you please explain to me what is really different between B and C ? and what do you prefer to use.

NB: I want to all users use the same variable. For example the first user who execute his database (here I mean FE DB) all user must use the same variable saved. For this reason I see to save the variable in a temporary table in the (BE DB)and all other use this variable.

Please advise me to proceed.


Thank you in advance


Best regards;

WASSIM S DACCACHE
May 9 '08 #20

NeoPa
Expert Mod 15k+
P: 31,186
In that case Wassim, you are thinking along the right lines.

The only point I would question is the temporary nature of the table. Certainly a table in the BE DB would be a good place to maintain this information.

Good luck with your project :)
May 9 '08 #21

100+
P: 222
Dear Neo;


Thank you for the direction that you drew for me. ;)



Best regards;
May 9 '08 #22

NeoPa
Expert Mod 15k+
P: 31,186
No problems :)

Let us know how you get on.
May 9 '08 #23

Post your reply

Sign in to post your reply or Sign up for a free account.