Link to home
Start Free TrialLog in
Avatar of Gilberto Sanches
Gilberto SanchesFlag for Suriname

asked on

Checkbox fixed information into Access table

Hi experts,

I need your help for a button or something like that to keep repeating a certain value until the button is unchecked.

Background:
Daily we insert around 40 recordsets of daily production into a Acces table. A split form is used for friendliness to insert data into a table.

Now certain informations for that period stays the same, like the date, the user, location and so on. Only a small part is new. But the information that is fixed for that period also needs to go into the table.

At the moment we have to reinsert the fixed information for that period manually. How can we automate this with a button or checkbox?
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

Use a checkbox or toggle button to initiate the holding of information to Form-scoped variables.
For example you have field1,field2...fieldn that you need to repeat them.
So just after
Option Compare Database

Open in new window

Dim mfield1 as Integer
Dim mfield2 as String
.....
Dim mfieldn as Date

Open in new window


and in the Current event
If me.chkBoxRepeat then
me.field1 =mfield1
me.field2 = mfield2
......
me.fieldn = mfieldn

Open in new window

and of course in the After Update of each field
mfieldn = me.fieldn

Open in new window

You don't need a button or the like, do it automatically in the AfterUpdate event of the form by setting the DefaultValue of the controls, like:


Me!OrderDate.DefaultValue = Me!OrderDate.Value
Me!UserID.DefaultValue = Me!UserID.Value
Me!LocationName.DefaultValue = "'" & Me!LocationName.Value & "'"      ' wrap text in quotes.

Open in new window

I would go with Gustav's recommendation, that is what I do.  Then, when you uncheck the checkbox or un-toggle the button, just set those default values back to NULL.


Dale

Avatar of Gilberto Sanches

ASKER

Okay, haven't applied the steps yet.. will do it soon. Thanks for the advise so far.
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.