JustJerry
09-01-2006, 08:35 AM
This in relation to a question I asked prior.
I am getting the following error:
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
I am selecting a random record from a table and I am unsure how to correctly check for the above condition. The table DOES contain records, so how do I code this so that if the condition is 'True', then look for a valid record.
Dim jk As String
Dim i As Integer
Dim RndNmbr As Single
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "SELECT * FROM tblJokeName", CurrentProject.Connection, adOpenStatic
'select the Jokes names
RndNmbr = Int((9 * Rnd + 1))
'randomize it
For i = 0 To RndNmbr
rst.MoveNext
Next i
'get to the random Record
jk = rst(1)
'assign it
rst.Close
Set rst = Nothing
DoCmd.Close
'close the main form
DoCmd.OpenForm stDocName
Form_frmStart.FrownImage.Visible = False
Form_frmStart.HelloImage.Visible = True
Form_frmStart.lblWelcome.Value = "WELCOME " & jk & " (aka " & [Forms]![frmTemp].Form!Name.Value & ")"
'display on joke_form......!
I am getting the following error:
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
I am selecting a random record from a table and I am unsure how to correctly check for the above condition. The table DOES contain records, so how do I code this so that if the condition is 'True', then look for a valid record.
Dim jk As String
Dim i As Integer
Dim RndNmbr As Single
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "SELECT * FROM tblJokeName", CurrentProject.Connection, adOpenStatic
'select the Jokes names
RndNmbr = Int((9 * Rnd + 1))
'randomize it
For i = 0 To RndNmbr
rst.MoveNext
Next i
'get to the random Record
jk = rst(1)
'assign it
rst.Close
Set rst = Nothing
DoCmd.Close
'close the main form
DoCmd.OpenForm stDocName
Form_frmStart.FrownImage.Visible = False
Form_frmStart.HelloImage.Visible = True
Form_frmStart.lblWelcome.Value = "WELCOME " & jk & " (aka " & [Forms]![frmTemp].Form!Name.Value & ")"
'display on joke_form......!