Solved

memory variables and form display questions

Posted on 2013-02-07
3
236 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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server functions 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 Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

856 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