Results 1 to 12 of 12
  1. #1
    nikolleee is offline Novice
    Windows 11 Access 2016
    Join Date
    Aug 2023
    Posts
    5

    Angry code builder

    Próbuję przygotować własną aplikację bazy danych, ale wystąpił błąd. Podczas tworzenia formularza, podczas konstruowania zdarzenia za pomocą konstruktora kodu, wpisuje kody:


    Dim strSQL As String
    Dim checkScript As Boolean

    Const MsgError = "Wypełnij wszystkie wymagane wartości"
    Const finScript = "Zapisz"
    Const scriptError = "Błąd. Brak danych ratować."
    Const tbl = "tblEmployeeInfo"
    Const col = "Nazwa_pracownika*, Dział*, Lider_zespołu*, Numer_PMS, Agencja, Data_rozpoczęcia*, EPT, Staplaar, Reachtruck, Hefttruck"

    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 & ") Wartości ( """ _
    & [Formularze]![frmAddPracownik]![Nazwa_pracownika*] & """, """ & [Formularze]![frmAddPracownik]![Dział*] _ & """, """ & [
    Formularze ]![frmAddEmployee]![Team_Leader*] & """, " & [Formularze]![frmAddEmployee]![pms_number] _
    If checkScript = Fasle Then MsgBox (scriptError) End If End Sub

    Ale ciągle pojawia się błąd podczas zapisywania — plik nie zostanie zapisany w tabeli. Proszę pomóż. Straciłem 2 dni i nie chcę się zniechęcać.


    https://www.goldenline.pl/grupy/Komp...-kodu,3933668/ - Polish question



















  2. #2
    nikolleee is offline Novice
    Windows 11 Access 2016
    Join Date
    Aug 2023
    Posts
    5

    Angry code builder

    I'm trying to prepare my own data base app but I got an error. When creating the form, at the time of constructing the event through the code constructor, enter the following codes:

    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

    but I keep getting an error when saving - the file does not want to be saved to the table. Please help. I lost 2 days and I don't want to get discouraged.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,963
    Please post code between CODE tags - use # icon on post editor toolbar.

    Have you step debugged? Have you Debug Compiled?

    You could provide db for analysis - follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,991
    Do you really have many field names ending in *?
    If so, I strongly recommend you rename all of them removing the *
    That is a wildcard in Access and could have unexpected outcomes.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    but I keep getting an error when saving
    That is of zero help to anyone who would try to help you. Always post the error number and message (don't expect everyone to lookup up the meaning of an error number for you). You need to learn how to troubleshoot as advised. Also can use debug.print lines to see your variables (e.g. value of sql statements you assign to a variable) in the immediate window:
    Code:
    start of code here
    strSQL = "Insert Into" & tbl & " (" & col & ") Values (""" _ ...etc.
    Debug.Print strSQL
    rest of code
    I figure that is where at least one problem lies due to lack of delimiting (using quotes around string portions or octothorpes around date portions as required) or a missing space. It may not be the issue you're having right now, but then again, you provided no info about that.
    Ditto on the code tags.
    Last edited by Micron; 08-20-2023 at 01:12 PM. Reason: added info
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,008
    Fasle?
    Obviously not tried to compile?

    It is called a language for a reason. You have to obey by it's syntax.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #7
    nikolleee is offline Novice
    Windows 11 Access 2016
    Join Date
    Aug 2023
    Posts
    5

    I'm so sorry, but I'm still fighting...

  8. #8
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    Post 6 was moderated, I'm posting to trigger email notifications.

    Note regarding attachments:

    https://www.accessforums.net/showthread.php?t=70301
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,008
    Quote Originally Posted by nikolleee View Post

    I'm so sorry, but I'm still fighting...
    No point fighting it, you just have to work with it.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  10. #10
    nikolleee is offline Novice
    Windows 11 Access 2016
    Join Date
    Aug 2023
    Posts
    5
    This is still my error message. :/
    Click image for larger version. 

Name:	1.png 
Views:	18 
Size:	12.5 KB 
ID:	50665

  11. #11
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,008
    As mentioned.
    Get rid of the * in the field names. Use ' for your strings, and # for your dates. Dates also need to be in mm/dd/yyyy format or yyyy-mm-dd format.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Office 365
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,991
    The message also shows you need a space between Into and tblEmployeeInfo
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 06-16-2022, 08:45 AM
  2. macro, expression or code builder??
    By Jen0dorf in forum Access
    Replies: 5
    Last Post: 10-17-2015, 11:46 AM
  3. Macro Builder and Code Builder
    By data808 in forum Macros
    Replies: 2
    Last Post: 01-12-2014, 11:28 AM
  4. Calculation in Code Builder for Sum & Subtraction
    By braveali in forum Programming
    Replies: 19
    Last Post: 03-07-2012, 12:32 AM
  5. Code Builder
    By nkenney in forum Forms
    Replies: 3
    Last Post: 11-04-2009, 10:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums