Solved

memory variables and form display questions

Posted on 2013-02-07
3
235 Views
Last Modified: 2013-02-08
Hello Again
Thanks so much for all the help getting me up to speed with access. I do have two questions which I hope can be answered.
1. How do you store memory variables in access. I remember DBASE III had a "STORE MEMORY TO <filename>" where the information was stored on a file  which could be retrieved at a later time or date.

2. When creating a form using a table that has two fields in it. If I want to display both fields yet only allow change on one of the fields how would this be done? In the access form?
0
Comment
Question by:PawloA
  • 3
3 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38865899
<I do have two questions which I hope can be answered.>
The rules of the site only allow one distinct question per post...

There are many ways to store variables, ...also "Scope" needs to be considered.

In a Sub you can do this:

Dim lngCustID as Long
...to "create" a variable to be used only in that sub

Then you can load it from a form control:
lngCustID =Me.txtCustID
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 38865919
If you nned a variable to "persist" throughout a "Form" (Module)
then you can do something like this( In the Form's code Module:

Private lngpvtCustID as Long

Sub Form_Open(Cancel As Integer)

    lngpvtCustID =me.txtCustID
End sub


Then you can also grab this variable in another sub in the same form:

sub YourButton_Click()
msgbox lngpvtCustID
end sub
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 38865944
To make a Variable persist through your entire application you have to create a Code Module.
Then do this:

Public lngpubCustID as long

Then you can set/Get this value form anywhere in your app..

But therein lies the danger.
You really need to have one place in your app where Public variables are set and reset, otherwise you will tie yourself in knots trying to figure out what the value is and how/where it was set...


In any event...
None of these variables will persist when the DB is closed though.

To do this you would load the values into a table..
...but this is another topic entirely...

Hope this all helped...

Lets see if other Experts can flesh out (or correct/clarify) the skeleton I sketched here...

;-)

JeffCoachman
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question