I am using disconnected ADO recordset to populate a custom object and an unbound form.
In the table, I am storing a number of related field values in single data type sngTask1 to sngTask15. Valid data are Null, 0, 0.5, 1
Using custom class clsTask to Get and Let the values for the table:
To populate the object from recordset, I use
Then assign value to custom object by
objTask.Task = ary 'where objTask is an instance of clsTask
To populate the object from the unbound form
I use similar loop concept
ary(intCounter) = Forms("frmTask" ).Controls(strC trlName)
then
objTask.Task = ary
When adding new record to the table, tblTask, I use SQL statement
strSQL = "INSERT INTO tblTask (sngTask1, sngTask2) Values("
strSQL = strSQL & objTask.Task(1) & ", " & objTask.Task(2) )
It works fine until objTask.Task(1) and objTask.Task(2) become Null
The INSERT INTO statement in run time become
"INSERT INTO tblTask(sngTask 1, sngTask2) Values(, ,))" and Syntax Error of INSERT INTO statement popped up.
How can I make the INSERT INTO statement work in this situation?
Thanks
Kin
In the table, I am storing a number of related field values in single data type sngTask1 to sngTask15. Valid data are Null, 0, 0.5, 1
Using custom class clsTask to Get and Let the values for the table:
Code:
Dim Private aryTaskVal() As Variant
Public Property Get Task() As Variant
Task = aryTaskVal
End Property
Public Property Let Task(Values As Variant)
aryTaskVal = Values
End Property
Code:
For intCounter = intLbound to intUbound
.
'strFieldName strore values of "sngTask1" to "sngTask15" when go through the For loop
.
ary(intCounter) = rstTask(strFieldName)
Next intCounter
objTask.Task = ary 'where objTask is an instance of clsTask
To populate the object from the unbound form
I use similar loop concept
ary(intCounter) = Forms("frmTask" ).Controls(strC trlName)
then
objTask.Task = ary
When adding new record to the table, tblTask, I use SQL statement
strSQL = "INSERT INTO tblTask (sngTask1, sngTask2) Values("
strSQL = strSQL & objTask.Task(1) & ", " & objTask.Task(2) )
It works fine until objTask.Task(1) and objTask.Task(2) become Null
The INSERT INTO statement in run time become
"INSERT INTO tblTask(sngTask 1, sngTask2) Values(, ,))" and Syntax Error of INSERT INTO statement popped up.
How can I make the INSERT INTO statement work in this situation?
Thanks
Kin
Comment