Results 1 to 4 of 4
  1. #1
    Join Date
    May 2015
    Posts
    1

    Question Unanswered: Run-Time Error '3134' HELP

    Hi,

    Im currently working on a project for a small database and need a bit of help with the following code, if anyone could point me in the right direction as to why I'm gettin the 3134 error, it would be much appreciated.

    Private Sub ButtonAddRecord_Click()
    'add data to table
    CurrentDb.Execute "INSERT INTO ModDatabase(ModID,Zone,ModificationName,Technician ,Date,SupervisorApproved,SupervisorName) " & _
    " VALUES(" & Me.txtModID & ",'" & Me.ComboZone & "','" & Me.txtModName & "','" & Me.txtTech & "','" _
    & Me.txtDate & "','" & Me.txtSupervisorApproved & "','" & Me.txtSupervisorName & "')"

    'refresh data in list on form
    ModDatabaseSubform.Form.Requery

    Thanks!

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Id suggest you examine the actual SQL you are sending tot eh SQL engine. debugging this sort fo things where you are building SQL is virtually impossible as it could be a code error, it could be a data error....
    I always recommend that you assign the value of the SQL to a variable before doing anything.... it makes debugging easier, and with modern VM operating systems there isn't a significant penalty on doing this

    Code:
    dim strSQL as string
    
    strSQL= "INSERT INTO ModDatabase(ModID,Zone,ModificationName,Technician ,Date,SupervisorApproved,SupervisorName) " & _
    " VALUES(" & Me.txtModID & ",'" & Me.ComboZone & "','" & Me.txtModName & "','" & Me.txtTech & "','" _
    & Me.txtDate & "','" & Me.txtSupervisorApproved & "','" & Me.txtSupervisorName & "')"
    CurrentDb.Execute strSQL
    either put a breakpoint on the code, or examine the value of strSQL when the code halts or use a msgbox to see what is in strSQL.
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,420
    Provided Answers: 7
    I do it this way

    SQL = ""
    SQL = SQL & "INSERT INTO ModDatabase(ModID,Zone,ModificationName,Technician ,Date,SupervisorApproved,SupervisorName) "
    SQL = SQL & " VALUES('[txtModID]','[combozone]','[txtModName]','[txtTech]','#[txtDate]#','[txtSupervisorApproved]') get the idea

    it look easyer to read

    then i do this

    SQL = replace(SQL,"[txtModID]",Me.txtModID)
    SQL = replace(SQL,"[combozone]",Me.combozone)
    SQL = replace(SQL,"[txtModName]",Me.txtModName)
    SQL = replace(SQL,"[txtDate]",format(Me.txtDate,"mm/dd/yyyy"))
    so on

    CurrentDb.Execute SQL


    bit more coding easyer to read I hate the """""" or the ""'"'"
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Agree wholeheartedly, although i tend to use the chr function to insert the relevant string delimiter. I tend to use the ' symbol to delimit text values so thats chr (39). EG:-
    Code:
    Strsql = "..... where atextcolumn =" & chr (39) & "blah" & chr (39)
    The only thing to bear in mind with delimited values is that if there is a risk the data may include that delimiter then pick another delimiter or escape the delimiter inside the text. The classic situsituations this can happen is in surnames such O'Flanagan, O'Reilly or if you have imperial measurements in text ( eg height 6'4")
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •