No need for table fields on a form

Cotswold

Well-known member
Local time
Today, 01:10
Joined
Dec 31, 2020
Messages
1,026
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.
 

Attachments

I'm not sure I understand what your example app is showing.
However, it has always been true that fields in the form record source don't need to be form controls to be available for use
That isn't the case on reports where you do need to include all fields as controls if you need to make use of them. However they can be hidden
 

Users who are viewing this thread

Back
Top Bottom