Private
Sub
cmdOkay_Click()
On
Error
GoTo
Mldg
Dim
strSQL
As
String
Dim
db
As
Database
Dim
rs
As
Recordset
Dim
strBestNr
As
String
Dim
intWahl
As
Integer
Dim
intWichtig
As
Integer
strBestNr =
Me
!KorrBestNr
If
strBestNr = Forms!frmBestellungen.BestNr
Then
MsgBox
"Sie verwenden bereits die BestNr: "
& strBestNr
Exit
Sub
End
If
Set
db = CurrentDb()
strSQL =
" SELECT tblBestellungen.BestNr FROM tblBestellungen WHERE BestNr = '"
& strBestNr &
"'"
Set
rs = db.OpenRecordset(strSQL, dbOpenSnapshot)
If
rs.RecordCount = 0
Then
MsgBox
"Okay"
, vbOKOnly,
"Microsoft Office Access"
Forms!frmBestellungen!BestNr = strBestNr
Forms!frmBestellungen.Refresh
Forms!PopFrmKorrBestNr.SetFocus
DoCmd.Close
Forms!frmBestellungen!KdNr.SetFocus
Exit
Sub
Else
MsgBox
"Leider existiert die Nummer "
& strBestNr &
" bereits:"
& vbCr & _
"Für die KdNr: "
, vbOKOnly,
"Micrsoft Office Access"
Exit
Sub
End
If
rs.Close
Mldg:
MsgBox Err.Description
End
Sub