Warning! dbase/Foxpro Dinosaur Alert! (translation ... Old Person please be kind)
Thanks in advance for any insight you can share so I can hopefully keep whatever grey matter I have left intact
Using 32 Bit mdb files to maintain backward compatibility with OFS Pro 2003 in 2003, 2016 and 2019
Grew up with the cardinal RULE: thou shalt NEVER use forms with BOUND fields
Seems to be a huge amount of noise on the topic of Unbound Fields with respect to determining a Dirty state ... in my poking around, I seem to have come away with the notion that: UNBOUND fields do NOT use Access's built-in Dirty Flag Logic (logic which appears to either use the Before & After properties OR the form.controls.item[n].oldvalue & value fields)
Is this notion valid? OR Have I missed something?
Does this mean one has to resort to manually creating code similar to the form load logic that populates the UNBOUND fields?
Basically, generate logic that compares each source value against its associated/current form field value?
OR
Adding After Events for each field? (there appears to be some suggestions that these events don't work properly with Unbound Fields)
Surely somebody has found an easier way of setting/triggering a form global gloIsMyFormDirtyFlag for Unbound Fields?
My attempt to create (simulate) a generic fnIsFormDirty function failed because it seems: oldvalue ALWAYS = value
Given a busy form with many Unbound fields that are being populated from an openrecordset, currently looking for a simple or easier way to satisfy the following form functions:Code:Private Function fnIsFormDirty() As Boolean ' expected to return true if form fields have changed Dim inI As Integer On Error Resume Next 'null content triggers errors just ignore and carry on (null typically means the source wasn't populated) fnIsFormDirty = False For inI = 0 To Me.Form.Controls.Count - 1 ' zero is a number ' didn't review all the access control types but the ones in use on this form >= 109 worked with this logic ' some fields are locked because they contain read only values If Me.Form.Controls.Item(inI).ControlType >= 109 And (Not Me.Form.Controls.Item(inI).Locked) Then fnIsFrmDirty = fnIsFrmDirty Or (Me.Form.Controls.Item(inI).Value <> Me.Form.Controls.Item(inI).OldValue) Debug.Print Me.Form.Controls.Item(inI).name; " "; Me.Form.Controls.Item(inI).Value; " "; Me.Form.Controls.Item(inI).OldValue End If Next End Function
Form Load()
populates the fields from openrecordset
Form cancel/close()
needs to determine if there has been a change and warn the user before tossing changes
Form save/close()
needs to determine if there has been a change and give the user a chance to recheck their changes
Form Delete()
needs to determine if there has been a change and give the user a chance to abort
Form Print()
needs to determine if there has been a change to provide the user the chance to save/update before printing
fncSave()
updates the openrecordset from the form fields
fnIsFormDirty()
returns true if form data has changed