T
Tom Green
Hi
I have many text boxes on a form. I use code to query a single table for
each text box, and deposit values from different records in these text
boxes. The table contains a Value for each hour for each day. I'd like to
now code that if a user changes a text box value, that value will be updated
in the record it came from - or if they enter a value for the first time it
will be Inserted in the database file.
From what I know the convenient form.dirty will not work, as the form is
unbound and all data is manipulated from code.
My attempt at the insert code:
Public Function InsertDoubleCell(frmReferrer As Form, sCellValue As String,
sPoint As Long, sDate As Date, sHourEnd)
On Error Resume Next
strSQL = "INSERT Hourly.Value " & sCellValue & ";"
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
Set frm = frmReferrer
With frm
Set ctl = frm.Controls(sCellXY)
ControlValue = Nz(rst("Value"), 0)
ctl.Value = ControlValue
End With
'Clost out the recordset and reset variables so they can be reused on next
pass
rst.Close
Set rst = Nothing
lngPointID = Null
strCellID = Null
ControlValue = 0
strSQL = ""
End Function
Any ideas?
Thanks in advance.
I have many text boxes on a form. I use code to query a single table for
each text box, and deposit values from different records in these text
boxes. The table contains a Value for each hour for each day. I'd like to
now code that if a user changes a text box value, that value will be updated
in the record it came from - or if they enter a value for the first time it
will be Inserted in the database file.
From what I know the convenient form.dirty will not work, as the form is
unbound and all data is manipulated from code.
My attempt at the insert code:
Public Function InsertDoubleCell(frmReferrer As Form, sCellValue As String,
sPoint As Long, sDate As Date, sHourEnd)
On Error Resume Next
strSQL = "INSERT Hourly.Value " & sCellValue & ";"
rst.Open strSQL, CurrentProject.Connection, adOpenKeyset,
adLockOptimistic
Set frm = frmReferrer
With frm
Set ctl = frm.Controls(sCellXY)
ControlValue = Nz(rst("Value"), 0)
ctl.Value = ControlValue
End With
'Clost out the recordset and reset variables so they can be reused on next
pass
rst.Close
Set rst = Nothing
lngPointID = Null
strCellID = Null
ControlValue = 0
strSQL = ""
End Function
Any ideas?
Thanks in advance.