ausmoran
Sep 13th, 2000, 08:13 AM
In my continuing effort to generate a random record, I am intrigued as to why the following code continues to select the same record from the database (despite the use of the RND function). If you can shed any light on this, I would appreciate it. Thanks in advance!
Private Sub cmdAddNew_Click()
Dim SpecificRecord As Long, i As Long, NumOfRecords As Long
Dim b As Integer
datCustomers.Recordset.MoveLast
NumOfRecords = datCustomers.Recordset.RecordCount
SpecificRecord = Int(NumOfRecords * Rnd)
If SpecificRecord = NumOfRecords Then
SpecificRecord = SpecificRecord - 1
End If
datCustomers.Recordset.MoveFirst
For i = 1 To SpecificRecord
datCustomers.Recordset.MoveNext
Cls
Next i
End Sub
Private Sub cmdAddNew_Click()
Dim SpecificRecord As Long, i As Long, NumOfRecords As Long
Dim b As Integer
datCustomers.Recordset.MoveLast
NumOfRecords = datCustomers.Recordset.RecordCount
SpecificRecord = Int(NumOfRecords * Rnd)
If SpecificRecord = NumOfRecords Then
SpecificRecord = SpecificRecord - 1
End If
datCustomers.Recordset.MoveFirst
For i = 1 To SpecificRecord
datCustomers.Recordset.MoveNext
Cls
Next i
End Sub