VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 4170 ClientLeft = 1365 ClientTop = 1605 ClientWidth = 7365 LinkTopic = "Form1" PaletteMode = 1 'UseZOrder ScaleHeight = 4170 ScaleWidth = 7365 Begin VB.CommandButton bsDSH Caption = "Datensatz &hinzufügen" Height = 350 Left = 3675 TabIndex = 14 Top = 3225 Width = 1750 End Begin VB.CommandButton bsDSL Caption = "Datensatz l&öschen" Height = 350 Left = 1875 TabIndex = 13 Top = 3225 Width = 1750 End Begin VB.CommandButton bsLDS Caption = "&letzter Datensatz" Height = 350 Left = 5475 TabIndex = 12 Top = 3675 Width = 1750 End Begin VB.CommandButton bsEDS Caption = "&erster Datensatz" Height = 350 Left = 75 TabIndex = 11 Top = 3675 Width = 1750 End Begin VB.CommandButton bsVDS Caption = "<-" Height = 350 Left = 1875 TabIndex = 10 Top = 3675 Width = 1750 End Begin VB.CommandButton bsNDS Caption = "->" Height = 350 Left = 3675 TabIndex = 9 Top = 3675 Width = 1750 End Begin VB.CommandButton bsEnde Caption = "Ende" BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 350 Left = 5475 TabIndex = 8 Top = 3225 Width = 1750 End Begin VB.CommandButton bsSpeichern Caption = "S&peichern" Height = 350 Left = 75 TabIndex = 7 Top = 3225 Width = 1750 End Begin VB.TextBox tfEKPreis BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 420 Left = 1950 TabIndex = 5 Text = "tfEKPreis" Top = 2400 Width = 1515 End Begin VB.TextBox tfBestand BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 420 Left = 1950 TabIndex = 3 Text = "tfBestand" Top = 1875 Width = 1515 End Begin VB.TextBox tfBez BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 420 Left = 1950 TabIndex = 0 Text = "tfBez" Top = 1350 Width = 3390 End Begin VB.TextBox tfTeileNr BeginProperty Font Name = "MS Sans Serif" Size = 12 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 420 Left = 150 TabIndex = 2 TabStop = 0 'False Text = "tfTeileNr" Top = 1350 Width = 1440 End Begin VB.Line Line1 BorderWidth = 2 X1 = 150 X2 = 4800 Y1 = 900 Y2 = 900 End Begin VB.Label Label4 Caption = "EKPreis" Height = 240 Left = 1200 TabIndex = 6 Top = 2550 Width = 690 End Begin VB.Label Label3 Caption = "Bestand" Height = 240 Left = 1125 TabIndex = 4 Top = 2025 Width = 765 End Begin VB.Label Label1 Caption = "Teiledaten pflegen" BeginProperty Font Name = "MS Sans Serif" Size = 24 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 540 Left = 150 TabIndex = 1 Top = 225 Width = 4290 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mdbHandy As Database Dim tbTeile As Recordset Dim mTeileNr As String Dim mAntwort As String Dim mMeldung As String Private Sub Form_Load() Form1.Show Set mdbHandy = OpenDatabase(App.Path + "\Handy.mdb") Set tbTeile = mdbHandy.OpenRecordset("TEILE", dbOpenTable) tbTeile.Index = "PrimaryKey" przLöschen End Sub Private Sub tfTeileNr_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then tbTeile.Seek "=", tfTeileNr.Text If tbTeile.NoMatch Then MsgBox ("Die TeileNummer gibt es nicht !") przLöschen Else przAnzeigen tfBez.SetFocus End If End If End Sub Private Sub tfBez_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then tfBestand.SetFocus End If End Sub Private Sub tfbestand_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If IsNumeric(tfBestand) Then tfEKPreis.SetFocus Else MsgBox ("Kein gültiger Bestand !") tfBestand = tbTeile!Bestand tfBestand.SetFocus End If End If End Sub Private Sub tfEKPreis_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If IsNumeric(tfEKPreis) Then bsSpeichern.SetFocus Else MsgBox ("Kein gültiger Einstandspreis !") tfEKPreis = tbTeile!EKPreis tfEKPreis.SetFocus End If End If End Sub Private Sub bsEDS_Click() tbTeile.MoveFirst przAnzeigen End Sub Private Sub bsLDS_Click() tbTeile.MoveLast przAnzeigen End Sub Private Sub bsNDS_Click() tbTeile.MoveNext If Not tbTeile.EOF Then przAnzeigen Else MsgBox ("Letzter Datensatz erreicht !") tbTeile.MovePrevious End If End Sub Private Sub bsVDS_Click() tbTeile.MovePrevious If Not tbTeile.BOF Then przAnzeigen Else MsgBox ("Erster Datensatz erreicht !") tbTeile.MoveNext End If End Sub Private Sub bsSpeichern_Click() tbTeile.Edit tbTeile!Bezeichnung = tfBez.Text tbTeile!Bestand = CSng(tfBestand.Text) tbTeile!EKPreis = CCur(tfEKPreis.Text) tbTeile.Update MsgBox ("Datensatz wurde gespeichert") End Sub Private Sub bsDSL_Click() przAnzeigen mMeldung = "Soll die TeileNr. " + tfTeileNr.Text + " wirklich gelöscht werden ?" _ + Chr(13) + "Beziehungen zu anderen Tabellen könnten betroffen sein !" mAntwort = MsgBox(mMeldung, 4, "Wichtige Frage vor dem Löschen:") If mAntwort = 6 Then ' Ja wurde gedrückt tbTeile.Delete tbTeile.MoveFirst End If przAnzeigen End Sub Private Sub bsDSH_Click() mTeileNr = InputBox("Neue Teilenummer eingeben:", "Eingabeaufforderung") If mTeileNr >= "10000" And mTeileNr <= "99999" And IsNumeric(mTeileNr) Then ' gültige Teilenummer eingegeben tbTeile.Seek "=", mTeileNr If tbTeile.NoMatch Then tbTeile.AddNew tbTeile!TeileNr = mTeileNr tbTeile!Bezeichnung = " " tbTeile!Bestand = 0 tbTeile!EKPreis = 0 tbTeile.Update tbTeile.Seek "=", mTeileNr przAnzeigen MsgBox ("Ergänzen Sie die Daten und Klicken Sie dann auf SPEICHERN !") tfBez.SetFocus Else MsgBox ("Die TeileNummer ist bereits vorhanden !") przAnzeigen End If Else MsgBox ("Ungültige TeileNummer !") End If End Sub Sub przLöschen() tfTeileNr = "" tfBez = "" tfEKPreis = "" tfBestand = "" tbTeile.MoveFirst tfTeileNr.SetFocus End Sub Sub przAnzeigen() tfTeileNr.Text = tbTeile!TeileNr tfBez.Text = tbTeile!Bezeichnung tfBestand.Text = tbTeile!Bestand tfEKPreis.Text = tbTeile!EKPreis End Sub Sub bsEnde_Click() tbTeile.Close mdbHandy.Close End End Sub