Hello everyone,
I want to make a button that selects a random record in a form. I used code from a previous thread:
http://www.access-programmers.co.uk/forums/showthread.php?t=248325
It seems to work exactly how I want it to except that it selects the first record every time before selecting a new random record. I thought this could be hidden by using the
function, but that doesn't seem to hide it from selecting the first record.
Does anyone know how to work around this or re-write this code to not select the first record while still keeping it random?
I want to make a button that selects a random record in a form. I used code from a previous thread:
http://www.access-programmers.co.uk/forums/showthread.php?t=248325
Code:
Dim RecordNumber As Integer Dim RecSor As String RecSor = Me.RecordSource RecordNumber = CInt(Rnd() * DCount("*", RecSor)) DoCmd.GoToRecord , , acFirst Me.Recordset.Move RecordNumber
It seems to work exactly how I want it to except that it selects the first record every time before selecting a new random record. I thought this could be hidden by using the
Code:
application.echo false
Does anyone know how to work around this or re-write this code to not select the first record while still keeping it random?