Results 1 to 9 of 9
  1. #1
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126

    Syntaks error 3134 ????


    Where is this "Syntaks error in 'Insert into' in this:

    Code:
    DoCmd.RunSQL "INSERT INTO PERSON (Fornavn, Mellemnavne, Efternavn, [Efternavn født], Køn, Fødselsdato, Fødested, Dødsdato, Dødssted, Arbejdsnotat) VALUES (" _
                                        & Me.PFornavn.Value & ", " _
                                        & Me.PMellemnavne.Value & ", " _
                                        & Me.PEfternavn.Value & ", " _
                                        & Me.PEfternavn_født.Value & ", " _
                                        & "?" & ", " _
                                        & Me.Fdato.Value & ", " _
                                        & Null & ", " _
                                        & Me.Ddato.Value & ", " _
                                        & Null & ", " _
                                        & "" & ");"
    I'm blind ... I can't see it !

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    Do not use 'null'.
    just don't use the field in the query,it will naturally be null.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    There's also the question mark. What's that supposed to do? Use a variable and this:

    http://www.baldyweb.com/ImmediateWindow.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,901
    I advise not to allow empty string in text fields.

    Agree with ranman, if you don't want to populate a field then don't include it in the action.

    You want a question mark character in field?
    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.

  5. #5
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    (Why don't I get any message that you answered this thread ?)

    The '?' is data for the gender in my DB - so it should be there !

    OK, just leave empty fields out - like this:

    Code:
    DoCmd.RunSQL "INSERT INTO PERSON (Fornavn, Mellemnavne, Efternavn, [Efternavn født], Køn, Fødselsdato, , Dødsdato, , ) VALUES (" _
                                        & Me.PFornavn.Value & ", " _
                                        & Me.PMellemnavne.Value & ", " _
                                        & Me.PEfternavn.Value & ", " _
                                        & Me.PEfternavn_født.Value & ", " _
                                        & "?" & ", " _
                                        & Me.Fdato.Value & ", " _
                                        & Me.Ddato.Value & ", " _
                                        & ");"
    I leave empty between commas in the FIELD-list ... how should it else match FIELDS to DATA ?

    Thx for the answers !

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Remove the empty spaces and superfluous commas in the first line.
    I still don't understand the use of a ? in the sql. If you must insert a ? surround it with single quotes '?'
    Why aren't you using the gender textbox value instead?

    Also, all the .Value can be removed as that is the default property.

    When you have issues with sql statements, the fastest solution is to use a debug.print line then paste the output into a query.
    It will highlight the first error it finds. Fix that and any subsequent errors found until it works
    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

  7. #7
    ksor's Avatar
    ksor is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    126
    Thx, again ... I just tried it and I got it to work !

    OK, I'll try removeing the .Value too !

    I changed the 'gender' to a combobox with 'M', 'F' and '?'

    I have to have the '?' in some cases I don't know the gender - yet.

    Thx again !

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,974
    Or you could use Nz(Me.cboGender,"") in your Sql and remove the '?' from the combo
    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

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,901
    I advise not to save empty string in tables. I would use Nz(Me.cboGender, "N"). N=Not Given.
    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.

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

Similar Threads

  1. Replies: 4
    Last Post: 03-26-2019, 02:40 PM
  2. insert getting runtime error 3134
    By vicsaccess in forum Programming
    Replies: 5
    Last Post: 12-06-2015, 09:50 PM
  3. runtime error 3134
    By TheLazyEngineer in forum Programming
    Replies: 2
    Last Post: 03-03-2015, 02:55 PM
  4. Syntax error 3134 for Add function
    By gaker10 in forum Programming
    Replies: 9
    Last Post: 06-16-2014, 12:06 PM
  5. Run-time Error '3134'
    By avitale in forum Access
    Replies: 2
    Last Post: 05-20-2012, 07:40 PM

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