Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

ich bin neu hier, kein Informatiker,

jedoch begeistere ich mich für die Programmierung.

Auf Grund meiner Tätigkeit als Projektleiter versuche ich stetig, die Übersichten zu verbessern, weshalb ich meine anstehende Techniker Arbeit mit dem Beruf verknüpfen möchte.

 

Leide habe ich nicht wirklich Erfahrung mit dem Thema VBA und Datenbanken in Access, sodass ich über erfolgreiche Tips sehr erfreut wäre.

Videos bei Youtube habe ich mir auch schon einige angesehen, wobei diese sich primär mit vba und excel befassen und ich nicht weis, worin genau der Unterschied in der Programmierung zu Access besteht.

 

Nun zurück zum Thema:

Ich habe eine VBA Oberfläche erstellt, womit ich gerne eine Bestandsübersicht (Access Tabelle) befüllen möchte.

Mein Problem, dass beim betätigen des CommandButton kein Datensatz geschrieben wird, sondern ein Fehler angezeigt wird.

VBA:

6d96d5-1582742518.png

Code:

Zitat

 

Private Sub CommandButton_Hinzufügen_Click()

'In erste Zeile schreiben
    Dim last As Integer
    last = .Cells(Rows.Count, 1).End(x1Up).Row + 1
    

'Standort
    Cells(last, 1).Value = TextBox_Standort

'Straße
    Cells(last, 2).Value = TextBox_Straße
    
'PLZ/ Ort
    Cells(last, 3).Value = TextBox_PLZ
    Cells(last, 4).Value = TextBox_Ort
    
'Hersteller
    Cells(last, 5).Value = ComboBox_Hersteller
    
'LS ID
    Cells(last, 6).Value = TextBox_LS_ID
    
'LP ID Links
    Cells(last, 7).Value = TextBox_LP_ID_Li
'LP ID Rechts
    Cells(last, 8).Value = TextBox_LP_ID_Re
    
'Gesamtleistung
    Cells(last, 9).Value = TextBox_Gesamtleistung
    
'Schließung
    ActiveSheet.Cells(last, 10).Value = ComboBox_Schließung
    
'Status
    If OptionButton_Aktiv.Value = True Then .Cells(last, 11).Value = "Aktiv"
    If OptionButton_Inaktiv = True Then .Cells(last, 11).Value = "Inaktiv"
    
'IB Datum
    Cells(last, 12).Value = TextBox_IB_Datum
    
'Techniker1
    Cells(last, 13).Value = ComboBox_Techniker1
'Techniker2
    Cells(last, 14).Value = TextBox_Techniker2
    
End Sub


Private Sub TextBox_Gesamtleistung_Enter()
    TextBox_Gesamtleistung = ""
End Sub

Private Sub TextBox_LP_ID_Li_Enter()
    TextBox_LP_ID_Li = ""
End Sub

Private Sub TextBox_LP_ID_Re_Enter()
    TextBox_LP_ID_Re = ""
End Sub

Private Sub TextBox_LS_ID_Enter()
    TextBox_LS_ID = ""
End Sub

Private Sub TextBox_Ort_Enter()
    TextBox_Ort = ""
End Sub

Private Sub TextBox_PLZ_Enter()
    TextBox_PLZ = ""
End Sub

Private Sub TextBox_Standort_Enter()
    TextBox_Standort = ""
End Sub


Private Sub TextBox_Straße_Enter()
    TextBox_Straße = ""
End Sub

Private Sub TextBox_Techniker2_Enter()
    TextBox_Techniker2 = ""
End Sub

Private Sub UserForm_Initialize()

'Standort
    TextBox_Standort = "Standort eintragen"
 
'Straße
    TextBox_Straße = "Straße eintragen"
    
'PLZ
    TextBox_PLZ = "PLZ"
    
'Ort
    TextBox_Ort = "Stadt eintragen"
    
'Hersteller
    With ComboBox_Hersteller
        .AddItem "Name1"
        .AddItem "Name2"
        .AddItem "Name3"
        .AddItem "Name4"
    End With

'LS ID
    TextBox_LS_ID = "Seriennummer eintragen"
    
'LP ID Links
    TextBox_LP_ID_Li = "Ladepunkt ID Links"
    
'LP ID Rechts
    TextBox_LP_ID_Re = "Ladepunkt ID Rechts"
    
'Gesamtleistung
    TextBox_Gesamtleistung = "Leistung in kW"

'Schließung
    With ComboBox_Schließung
        .AddItem "Herstellerschließung"
        .AddItem "Kundenschließung"
    End With
    
'Status
    OptionButton_Aktiv.Value = True

'Inbetriebnahme-Datum
    TextBox_IB_Datum.Value = Format(Now, "dd.mm.yyyy")
    
'Techniker 1
    With ComboBox_Techniker1
        .AddItem "Techniker1"
        .AddItem "Techniker2"
        .AddItem "Techniker3"
    End With
'Techniker 2
    TextBox_Techniker2 = "Name des Montagehelfer"

End Sub

 

Fehler:

0d1f3f-1582742713.png

 

Was kann man ändern?

Bzw. wie lautet hier der richtige Befehl, um bei jedem Hinzufügen eine neue Zeile in der Datenbank "Bestandliste" zu erstellen?

 

 

Vielen Dank

Freundliche Grüße

Ingo

  • 2 Monate später...

Hallo, die Fehlermeldung hat erstmal primär nichts mit der DB oder dem Speichern zu tun, sondern ist ein Compilerfehler.
Vermutlich kommt sie aus dem Abholen der Werte in CommandButton_Hinzufügen_Click(), denn dort kannst du in Cell(....).Value= nicht einfach die Controls zuweisen sondern musst dich auf deren Eigenschaften beziehen.

Ansonsten tue dir selber einen Gefallen und mach ein vernünftiges Fehlerhandling (on error ...) sonst suchst du dich tot.

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.