I am trying to figure out the best way to store and retrieve dates. I keep getting errors when I run the following code.:
(For retrieving records from the database and putting them into the mask edit control)
Sub EditRecord(aForm As Form, aRecordset As ADODB.Recordset)
Dim c As Control
For Each c In aForm
If TypeOf c Is MaskEdBox Then
If IsNull(aRecordset.Fields(c.DataField).Value) = False Then
c.Text = aRecordset.Fields(c.DataField).Value
End If
End If
Next c
End Sub
(For saving records from the mask edit box to the database)
Sub SaveRecord(aForm As Form, aRecordset As ADODB.Recordset)
'Save a new record or update a old one.
Dim c As Control
For Each c In aForm
If TypeOf c Is MaskEdBox Then
aRecordset.Fields(c.DataField).Value = (c.Text)
End If
Next c
Set aRecordset.ActiveConnection = dbCTS
aRecordset.UpdateBatch 'adAffectAll
I keep getting "Invalid Property" error when I try to run the GetRecord sub routine. There also can be problems if there is no data either in the database or the mask edit box Or if the mask edit box has IncludePrompts set to yes.
In short, I am trying to figure out what would be the most standard way to enter, save and redisplay datees
Thanks,
Dan
(For retrieving records from the database and putting them into the mask edit control)
Sub EditRecord(aForm As Form, aRecordset As ADODB.Recordset)
Dim c As Control
For Each c In aForm
If TypeOf c Is MaskEdBox Then
If IsNull(aRecordset.Fields(c.DataField).Value) = False Then
c.Text = aRecordset.Fields(c.DataField).Value
End If
End If
Next c
End Sub
(For saving records from the mask edit box to the database)
Sub SaveRecord(aForm As Form, aRecordset As ADODB.Recordset)
'Save a new record or update a old one.
Dim c As Control
For Each c In aForm
If TypeOf c Is MaskEdBox Then
aRecordset.Fields(c.DataField).Value = (c.Text)
End If
Next c
Set aRecordset.ActiveConnection = dbCTS
aRecordset.UpdateBatch 'adAffectAll
I keep getting "Invalid Property" error when I try to run the GetRecord sub routine. There also can be problems if there is no data either in the database or the mask edit box Or if the mask edit box has IncludePrompts set to yes.
In short, I am trying to figure out what would be the most standard way to enter, save and redisplay datees
Thanks,
Dan