Anna Sutor

Anna Sutor Trainer Warehouse
Employee,

Temat: Access - Formularz - konstruktor kodu

Hello,

Probuje przygotowac wlasna data base app ale pojawil mi sie blad. Podczas tworzenia formularza, w momencie konstruowania zdarzenia poprzez konstruktor kodu, wpisuje kody:
Option Compare Database
Private Sub Polecenie22_Click()

Dim strSQL As String
Dim checkScript As Boolean

Const MsgError = "Fill in all required values"
Const finScript = "Save"
Const scriptError = "Error. Data not save."
Const tbl = "tblEmployeeInfo"
Const col = "Employee_Name*, Department*, Team_Leader*, PMS_number, Agency, Start_Date*, EPT, Staplaar, Reachtruck, Heftruck"

On Error GoTo Errorzone

checkScript = False

If IsNull([Forms]![frmAddEmployee]![Employee_Name*]) = True Then
MsgBox (MsgError)
Exit Sub
End If

If IsNull([Forms]![frmAddEmployee]![Department*]) = True Then
MsgBox (MsgError)
Exit Sub
End If

If IsNull([Forms]![frmAddEmployee]![Team_Leader*]) = True Then
MsgBox (MsgError)
Exit Sub
End If

If IsNull([Forms]![frmAddEmployee]![Start_Date*]) = True Then
MsgBox (MsgError)
Exit Sub
End If

strSQL = "Insert Into" & tbl & " (" & col & ") Values (""" _
& [Forms]![frmAddEmployee]![Employee_Name*] & """, """ & [Forms]![frmAddEmployee]![Department*] _
& """, """ & [Forms]![frmAddEmployee]![Team_Leader*] & """, " & [Forms]![frmAddEmployee]![pms_number] _
& ", """ & [Forms]![frmAddEmployee]![Agency] & """, " & [Forms]![frmAddEmployee]![Start_Date*] & ", " & [Forms]![frmAddEmployee]![ept] _
& ", " & [Forms]![frmAddEmployee]![staplaar] & ", " & [Forms]![frmAddEmployee]![reachtruck] & ", " & [Forms]![frmAddEmployee]![heftruck] & ")"
MsgBox (strSQL)
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True

checkScript = True

MsgBox (finScript)

DoCmd.Close acForm, "frmAddEmployee"

Errorzone:
If checkScript = Fasle Then
MsgBox (scriptError)
End If

End Sub

ale ciagle pojawia mi sie blad podczas zapisu - plik sie nie chce zapisac do tabeli. Prosze o pomoc. Stracilam 2 dni a nie chce sie zniechecac.
Marzanna Szulta

Marzanna Szulta właściciel, Usługi
Informatyczne
SZULTASET

Temat: Access - Formularz - konstruktor kodu

Ten SQL kwerendy bardzo mi się nie podoba, muszę się temu dokładnie przyjrzeć.
Mam pytanie: pola w tym formularzu są niezwiązane?
Anna Sutor

Anna Sutor Trainer Warehouse
Employee,

Temat: Access - Formularz - konstruktor kodu

Nie, nie są.
Marzanna Szulta

Marzanna Szulta właściciel, Usługi
Informatyczne
SZULTASET

Temat: Access - Formularz - konstruktor kodu

Wrzuciłam na swój blog o Accessie przykład takiego rozwiązania
https://access.marzatela.pl/dodawanie-nowego-rekordu/



Wyślij zaproszenie do