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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Standardlösungen > Prüfen, ob bestimmter Datensatz existiert

Prüfen, ob bestimmter Datensatz existiert

Problemstellung Sie möchten überprüfen, ob ein bestimmter Datensatz schon existiert.

Lösung Bevor Sie Daten aus einem Formular in einer Tabelle speichern, ist es in vielen Fällen sinnvoll, zu überprüfen, ob diese Daten dort schon existieren. Im Formular frmAusleihe macht es z.B. keinen Sinn, dieselbe Ausleihe zweimal zu speichern. Deshalb wird vor dem Speichern überprüft, ob es die zu speichernde Ausleihe in der Tabelle schon gibt.

Codebeispiel aus Verleih, Form_frmAusleihe, Prozedur cmdSpeichern_Click():

lngBuchId = Me!frmAusleihe_ufoBuecher!buch_id
lngPerId = Me!frmAusleihe_ufoPersonen!per_id
lngGibtsSchon = DCount("buch_id_f", "tblAusleihe", "buch_id_f=" & Str(lngBuchId) & _
                                    " AND per_id_f=" & Str(lngPerId) & _
                                    " AND aus_bis IS NULL")
If lngGibtsSchon > 0 Then
   MsgBox "Diese Ausleihe wurde bereits eingetragen!"
   Exit Sub
End If

  

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