Solved

memory variables and form display questions

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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now