I am creating a rotation of numbers from 1 to 20. With the code below, I trying to the update the field RANK of table tblRanks with value from 1 to 20, everytime a user click on cmdRank button. With each click, each field value is incremented with 1, unless the current value is 20, then reset it to 1.
Field rank is Integer data type. I keep getting Type Mismatch error (runtime 13) on line :"Set Rs1 = CurrentDb.openrecordset("tblRanks""
Any ideas? Thanks.
Here is my code:
Private Sub CmdRank_Click()
Dim rank As Integer
Dim Rs1 As Recordset
Set Rs1 = CurrentDb.openrecordset("tblRanks"
Rs1.MoveFirst 'Go to first record
Do Until Not Rs1.EOF 'Read until end of file
If rank = 20 Then rank = 1 'if 20 reset to 1
rank = rank + 1 ' else add 1
Rs1.MoveNext 'go to next record
Loop
Rs1.Close
Set Rs1 = Nothing
End Sub
Field rank is Integer data type. I keep getting Type Mismatch error (runtime 13) on line :"Set Rs1 = CurrentDb.openrecordset("tblRanks""
Any ideas? Thanks.
Here is my code:
Private Sub CmdRank_Click()
Dim rank As Integer
Dim Rs1 As Recordset
Set Rs1 = CurrentDb.openrecordset("tblRanks"
Rs1.MoveFirst 'Go to first record
Do Until Not Rs1.EOF 'Read until end of file
If rank = 20 Then rank = 1 'if 20 reset to 1
rank = rank + 1 ' else add 1
Rs1.MoveNext 'go to next record
Loop
Rs1.Close
Set Rs1 = Nothing
End Sub