M
Michelle
HELP! I have a form in Access that has 5 check boxes in a subform.
DSRTaskCode is new field. I had to put a dummy field in DSR table to put on
form. I couldn't create an option group- it wouldn't work. These need to be
evaluated into 1 field. This will be added to a permanent table. ztblDDT is
temp table. I'm using the below code. It processes the second record and
ends. Where am I making my mistake?
Dim rs As ADODB.Recordset
Dim strSQLStmt As String
Dim TaskCode As String
strSQLStmt = "SELECT ztblDDT.DeptID, ztblDDT.DSRPartNo, ztblDDT.DSRTask1,
ztblDDT.DSRTask2, ztblDDT.DSRTask3, ztblDDT.DSRTask4, ztblDDT.DSRTask5 FROM
ztblDDT WHERE (((ztblDDT.DSRTask1) = Yes)) Or (((ztblDDT.DSRTask2) = Yes)) Or
(((ztblDDT.DSRTask3) = Yes)) Or (((ztblDDT.DSRTask4) = Yes)) Or
(((ztblDDT.DSRTask5) = Yes))"
Set rs = New ADODB.Recordset
rs.Open strSQLStmt, CurrentProject.Connection, adOpenForwardOnly,
adLockReadOnly
With rs
rs.MoveFirst
Do Until rs.EOF
'Now that I have only the records that were checked
'they need to be converted for the TaskCode field in the permanent table.
If rs!DSRTask1 = yes Then
TaskCode = "97"
ElseIf rs!DSRTask2 = yes Then
TaskCode = "98"
ElseIf rs!DSRTask3 = yes Then
TaskCode = "99"
ElseIf rs!DSRTask4 = yes Then
TaskCode = "100"
ElseIf rs!DSRTask5 = yes Then
TaskCode = "101"
End If
Debug.Print rs.GetString
Debug.Print TaskCode
rs.MoveNext
Loop
End With
DSRTaskCode is new field. I had to put a dummy field in DSR table to put on
form. I couldn't create an option group- it wouldn't work. These need to be
evaluated into 1 field. This will be added to a permanent table. ztblDDT is
temp table. I'm using the below code. It processes the second record and
ends. Where am I making my mistake?
Dim rs As ADODB.Recordset
Dim strSQLStmt As String
Dim TaskCode As String
strSQLStmt = "SELECT ztblDDT.DeptID, ztblDDT.DSRPartNo, ztblDDT.DSRTask1,
ztblDDT.DSRTask2, ztblDDT.DSRTask3, ztblDDT.DSRTask4, ztblDDT.DSRTask5 FROM
ztblDDT WHERE (((ztblDDT.DSRTask1) = Yes)) Or (((ztblDDT.DSRTask2) = Yes)) Or
(((ztblDDT.DSRTask3) = Yes)) Or (((ztblDDT.DSRTask4) = Yes)) Or
(((ztblDDT.DSRTask5) = Yes))"
Set rs = New ADODB.Recordset
rs.Open strSQLStmt, CurrentProject.Connection, adOpenForwardOnly,
adLockReadOnly
With rs
rs.MoveFirst
Do Until rs.EOF
'Now that I have only the records that were checked
'they need to be converted for the TaskCode field in the permanent table.
If rs!DSRTask1 = yes Then
TaskCode = "97"
ElseIf rs!DSRTask2 = yes Then
TaskCode = "98"
ElseIf rs!DSRTask3 = yes Then
TaskCode = "99"
ElseIf rs!DSRTask4 = yes Then
TaskCode = "100"
ElseIf rs!DSRTask5 = yes Then
TaskCode = "101"
End If
Debug.Print rs.GetString
Debug.Print TaskCode
rs.MoveNext
Loop
End With