Garner,
You might be jumping to the wrong solutionâmaybe.
Though databases are, of course, useful for this sort of thing, that might not be the perfect fit here (though also it might be...).
There are a couple of things to contemplate.
There is a storage mechanism using defined types (the same thing as structures in C).
If you define a type, you can save &retrieve all of the âfieldsâ of that type in one step, using file access procedures built into
VB.
Using that technique, you could do this:
- Create a type, having one âfieldâ per datum, a field of the proper data type.
Code:
Public Type MyType
FName As String
LName As String
. . .
End Type
- Create a global variable of that type.
Code:
Public tmpType As MyType
- In each control, use the OnUpdate/OnChange/OnEtc event to change the value of the field in the variabe that corresponds to that datum, and save the variable to a temp, local file.
Code:
Private Sub txtFName_OnUpdate()
tmpType.FName = txtFName.Text
SaveMyTmpVar ' A Sub youâve written to do the saving.
End Sub
This way, the file would be almost 100% up to date at all times, and sometimes even [u]at</u> 100%.
When you âsaveâ the contents of the form, delete the file.
If, when the user opens the form, there is a temp file in existence locally, there were lost data, and you can reload the form from the contents of the file.
Since data in a form are usually not relational, a flat-file storage approach is often adequate. After all, these data have not been tagged by the user for saving, so adding them to the database can be premature.