View Full Version : Blocking of historical data before changes


Gregof1976
10-20-2011, 12:25 AM
I created a simple database to record time for manufacturing department. End users (about 15), day by day, for each worker register data using a special dedicated form.
Within one month of the table is registered about 10 - 12 thousand of records. At the end of the month registered time is being presented in different variants.

Data for the next month are filled in with the same manner as the month before and they are keep in the same table. This is where my problem occurs:

On the one hand, keeping data in one table allows for flexible analysis in various time intervals, what is a very big advantage, which I use in everday work.
On the other hand, historical data are subject to change by the end user, which unfortunately I experience every day.

Therefore I trying to find such solution where historical data will be maximum protected (before appending and changing records in closed period) and from the other side should still allowing make analysis in various time intervals for example, at the turn of month.

Can you suggest any sensible solution?

spikepl
10-20-2011, 01:18 AM
Flag historical data with a boolean, and disallow changes to such flagged records in your form - in the oncurrent event put some code: if MyHistoricalFlag then all controlsOnTheRecord.locked=true else false

Gregof1976
10-20-2011, 02:32 AM
Flag historical data with a boolean, and disallow changes to such flagged records in your form - in the oncurrent event put some code: if MyHistoricalFlag then all controlsOnTheRecord.locked=true else false

Thanks for your tips. I tried play with some Union Table, but this solution most probably will works better :)

Gregof1976
10-20-2011, 04:01 AM
I'v created additional filel in table with bolean and I apply code as you suggested but it doesen't work...do you have what I made wrong?:confused:



if MyHistoricalFlag then

Me.controlsOnTheRecord.locked=true
Else

Me.controlsOnTheRecord.locked=False
Else


End If
End Sub

And this way I tried..


If MyHistoricalFlag Then
controlsOnTheRecord.Locked = True
Else
controlsOnTheRecord.Locked = False

End If
End Sub

spikepl
10-20-2011, 04:29 AM
errr that was pseudo code to show the idea

you need to either lock each specific control individually

like

Me.SomeTextBox.Locked=True


or loop over them.

dim ctl as Control
for each ctl in me.controls
if me.myhistoricalflag then
ctl.locked=false
else
ctl.locked=true
end if
next

this assumes that you are in a subform in datasheetview. If not then you'd have to exclude irrelevant controls from the loop, otherwise all controls on the form get locked.

Gregof1976
10-20-2011, 10:54 PM
Still doesen't work as I expect. When I flag one record then it caused that all records in form are locked...

Can I get more support?

spikepl
10-21-2011, 03:14 AM
The flag must be a field on each record. (in a form, if you add an unbound control in the details section, all records will have the same value. To set values for each record, the control must be bound to that record).

Gregof1976
10-21-2011, 05:26 AM
The flag must be a field on each record. (in a form, if you add an unbound control in the details section, all records will have the same value. To set values for each record, the control must be bound to that record).


It looks like that is over my perception ...:o

Gregof1976
10-22-2011, 02:59 AM
I put code in module 'on current' and then start working :D


Private Sub Form_Current()
If Me.approved = False Then
Data.Locked = False
Else
Data.Locked = True
End If
End Sub