Cotswold
Well-known member
- Local time
- Today, 22:29
- Joined
- Dec 31, 2020
- Messages
- 1,030
After all of the years using Access, the other day I accidentally dropped on something I had never come across before.
I have always used form variables as memory variables. Mainly just because I can in Access and also so I can easily see them if I need to. I will store what otherwise would be a Globals on an always-open form on startup. Also regularly using form variables when processing data and passing it between screens and objects. During development it has the advantage of displaying those variables for me to check as they are modified, or added.
When the program is completed I'll just hide them.
One thing I regularly do is to use data from a datasheet and write it to another form, use them for calculations, parameters, passing to functions etc.
In the past if a datasheet had variables I needed, then I would have all of the fields required on the datasheet form and then go to the bother of hiding, and locking them. By accident I found that simply having the variables in the underlying table, or query that feeds the datasheet is actually sufficient.
So to use a field variable a form simply has a query or table as its datasource and there is need to have all of the actual fields required on the form.
I attach a simple example with a datasheet in a subform (F10Test_1) with two fields in use and three other fields shown on its mainform (F10Test_0).
The fields on the mainform are only in the underlying table or query to the datasheet and have no need to actually be on the datasheet form.
I thought I'd post a simple example for those out there who don't know about this shortcut.
I have always used form variables as memory variables. Mainly just because I can in Access and also so I can easily see them if I need to. I will store what otherwise would be a Globals on an always-open form on startup. Also regularly using form variables when processing data and passing it between screens and objects. During development it has the advantage of displaying those variables for me to check as they are modified, or added.
When the program is completed I'll just hide them.
One thing I regularly do is to use data from a datasheet and write it to another form, use them for calculations, parameters, passing to functions etc.
In the past if a datasheet had variables I needed, then I would have all of the fields required on the datasheet form and then go to the bother of hiding, and locking them. By accident I found that simply having the variables in the underlying table, or query that feeds the datasheet is actually sufficient.
So to use a field variable a form simply has a query or table as its datasource and there is need to have all of the actual fields required on the form.
I attach a simple example with a datasheet in a subform (F10Test_1) with two fields in use and three other fields shown on its mainform (F10Test_0).
The fields on the mainform are only in the underlying table or query to the datasheet and have no need to actually be on the datasheet form.
I thought I'd post a simple example for those out there who don't know about this shortcut.