When i try to run this program, a error shown i haven't set object variable or with block variable.
Does anyone know what's problem of the following VB code?
Private Sub Command8_Click()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = CurrentProject.Connection
rst.Open "salesperson", cnn, adOpenKeyset, adLockOptimistic, adCmdTable
rst.MoveFirst
total = 0
Do While Not rst.EOF
total = total + (rst![basic salary] + rst![sales] * rst![commission rate])
rst.MoveNext
Loop
rst.Close
cnn.Close
MsgBox "total amount=" + Str(total)
End Sub
Does anyone know what's problem of the following VB code?
Private Sub Command8_Click()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Set cnn = CurrentProject.Connection
rst.Open "salesperson", cnn, adOpenKeyset, adLockOptimistic, adCmdTable
rst.MoveFirst
total = 0
Do While Not rst.EOF
total = total + (rst![basic salary] + rst![sales] * rst![commission rate])
rst.MoveNext
Loop
rst.Close
cnn.Close
MsgBox "total amount=" + Str(total)
End Sub