ernmeister
Nov 17th, 2000, 12:12 PM
I am trying to use the DSUM function in Access. Here is the code as I currently have it.
Private Sub Command0_Click()
Dim rstUpdate As Recordset, dbs As Database
Dim intWeek As Integer, intTotal As Integer
Dim strLine As String
Set dbs = CurrentDb
Set rstUpdate = dbs.OpenRecordset("USED", dbOpenTable)
With rstUpdate
.MoveFirst
Do While Not .EOF
intWeek = !week
strLine = !Line
intTotal = DSum("[MIS]+[pty]", "USED", "[WEEK] = " & intWeek And "[LINE] = " & strLine)
.Edit
!totalused = intTotal
.Update
.MoveNext
Loop
End With
End Sub
When I run the program, I get a run-time error '13' and it states there is a type mismatch. It highlights the line of code using the DSUM function. I'm sure it is due to the code involving ("[LINE] = " & strLine) because it will work it I take it out. But I have to use the line as part of the criteria in order to get the info I need. Anyone know how it should be written?
Thanks,
ern
Private Sub Command0_Click()
Dim rstUpdate As Recordset, dbs As Database
Dim intWeek As Integer, intTotal As Integer
Dim strLine As String
Set dbs = CurrentDb
Set rstUpdate = dbs.OpenRecordset("USED", dbOpenTable)
With rstUpdate
.MoveFirst
Do While Not .EOF
intWeek = !week
strLine = !Line
intTotal = DSum("[MIS]+[pty]", "USED", "[WEEK] = " & intWeek And "[LINE] = " & strLine)
.Edit
!totalused = intTotal
.Update
.MoveNext
Loop
End With
End Sub
When I run the program, I get a run-time error '13' and it states there is a type mismatch. It highlights the line of code using the DSUM function. I'm sure it is due to the code involving ("[LINE] = " & strLine) because it will work it I take it out. But I have to use the line as part of the criteria in order to get the info I need. Anyone know how it should be written?
Thanks,
ern