G
Greg Green
Hello
I have several objectives and need advice on them:
1) Use a recordset object in code from an unbound form to select from a
table into each of about a hundred text boxes on the form. *I have this
working well* by cycling through a function (below) once for each text box.
2) If a user changes the value in a text box, I want to UPDATE that value in
the table by calling a function that "rewrites" the value in the table. From
what I know, the "form.dirty" property is not usable in this situation as
the form is unbound.
3) If a user wants to author the value in a text box for the first time
(value is not yet in database) I'd like to INSERT a record.
Thanks in advance!
----------------------------------------------------------------
I call the function below with this code:
modData.PopulateDoubleCell Me, "H28", "5005", "11/21/2003"
----------------------------------------------------------------
I use the function below to select a value into a recordset object and
deposit it into each text box. I'm trying to use something like it to author
back to the table as well as update the table if a value has changed.
Public Function PopulateDoubleCell(frmReferrer As Form, sCellXY As String,
sPoint As Long, sDate As Date)
On Error Resume Next
strSQL = "SELECT DailyOps_Values.Value FROM DailyOps_Values
WHERE(((DailyOps_Values.Date)=#" & sDate & "#)
AND((DailyOps_Values.PointID)= " & sPoint & "));"
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 in other
procedures
rst.Close
Set rst = Nothing
lngPointID = Null
strCellID = Null
ControlValue = 0
strSQL = ""
End Function
I have several objectives and need advice on them:
1) Use a recordset object in code from an unbound form to select from a
table into each of about a hundred text boxes on the form. *I have this
working well* by cycling through a function (below) once for each text box.
2) If a user changes the value in a text box, I want to UPDATE that value in
the table by calling a function that "rewrites" the value in the table. From
what I know, the "form.dirty" property is not usable in this situation as
the form is unbound.
3) If a user wants to author the value in a text box for the first time
(value is not yet in database) I'd like to INSERT a record.
Thanks in advance!
----------------------------------------------------------------
I call the function below with this code:
modData.PopulateDoubleCell Me, "H28", "5005", "11/21/2003"
----------------------------------------------------------------
I use the function below to select a value into a recordset object and
deposit it into each text box. I'm trying to use something like it to author
back to the table as well as update the table if a value has changed.
Public Function PopulateDoubleCell(frmReferrer As Form, sCellXY As String,
sPoint As Long, sDate As Date)
On Error Resume Next
strSQL = "SELECT DailyOps_Values.Value FROM DailyOps_Values
WHERE(((DailyOps_Values.Date)=#" & sDate & "#)
AND((DailyOps_Values.PointID)= " & sPoint & "));"
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 in other
procedures
rst.Close
Set rst = Nothing
lngPointID = Null
strCellID = Null
ControlValue = 0
strSQL = ""
End Function