Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Quelltext

Option Explicit

Private Sub Befehl1_Click()     ' Start
Dim db As Database
Dim rs As Recordset
Dim i As Integer, z As Integer
  Set db = CurrentDb
  Set rs = db.OpenRecordset("Personen", dbOpenTable)
  Randomize                     ' startet Zufallsgenerator
  z = Int(rs.RecordCount * Rnd) ' Zufallszahl ermitteln
  rs.MoveFirst
  i = 0

Das Recordset wird in einer Schleife so lange durchlaufen, bis die erzeugte Zufallszahl der Datensatznummer entspricht:

Do
   i = i + 1
   rs.MoveNext
   If i = z Then Exit Do
  Loop While Not rs.EOF

Die Anzeige:

  Text1.Value = rs.Fields("Nachname") & ", " & rs.Fields("Vorname")
  Text2.Value = rs.Fields("Geburtstag")
End Sub

Private Sub Befehl2_Click()     ' Beenden
 DoCmd.Close
End Sub

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint