A
Al
I have a table with 2 variables based upon years (dblYr04Val, cblYr04Val). I
would like to have the following subroutine set the value of dblComValue
based upon the value of global variable sYear.
I get error 13 – Type mismatch on line 10. How do I code this so the
variable substitution will work?
Public Sub ProcessData()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim dblYrValue as Double
Dim strYrValue as String
1. Set rst = dbs.OpenRecordset("tblData", dbOpenDynaset)
2. If sYear = "2004" Then
3. strYrValue = "![dblYr04Val]"
4. Else
5. strYrValue = "![dblYr05Val]"
6. End If
7. With rst
8. .MoveFirst
9. Do While Not .EOF
10. dblComValue = strYrValue
11. .MoveNext
12. Loop
13. End With
14. Set rst = Nothing
End Sub
would like to have the following subroutine set the value of dblComValue
based upon the value of global variable sYear.
I get error 13 – Type mismatch on line 10. How do I code this so the
variable substitution will work?
Public Sub ProcessData()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim dblYrValue as Double
Dim strYrValue as String
1. Set rst = dbs.OpenRecordset("tblData", dbOpenDynaset)
2. If sYear = "2004" Then
3. strYrValue = "![dblYr04Val]"
4. Else
5. strYrValue = "![dblYr05Val]"
6. End If
7. With rst
8. .MoveFirst
9. Do While Not .EOF
10. dblComValue = strYrValue
11. .MoveNext
12. Loop
13. End With
14. Set rst = Nothing
End Sub