Results 1 to 3 of 3
  1. #1
    Lehans is offline Novice
    Windows 10 Access 2010 64bit
    Join Date
    Apr 2017
    Posts
    1

    Angry I am getting error 3134 when closing an empty form for database

    Private Sub Form_Close()
    Dim sSQL, stringSQL As String
    Dim rst As DAO.Recordset

    sSQL = "SELECT BarCode, [Goods Name] FROM tblInventory WHERE BarCode='" & Me.ID & "'"
    Set rst = CurrentDb.OpenRecordset(sSQL)
    If rst.EOF Then
    stringSQL = "INSERT INTO tblInventory(BarCode,[Goods Name],Unit,[Unit Price],[Initial Stock],[Current Stock],[Exit Item]) values('" & Me.ID & "','" & Me.Description & "','" & Me.Unit & "'," & Replace(Format(Me.Price, "0.00"), ",", ".") & "," & Me.Amount & "," & Me.Amount & ",0)"


    DoCmd.SetWarnings False
    DoCmd.RunSQL (stringSQL)
    DoCmd.SetWarnings True
    Else
    stringSQL = "UPDATE tblInventory SET [Current Stock]=[Current Stock]+" & Me.Amount & " WHERE BarCode='" & Me.ID & "'"
    DoCmd.SetWarnings False
    DoCmd.RunSQL (stringSQL) // the error is at this location//
    DoCmd.SetWarnings True
    End If
    rst.Close
    End Sub

    Private Sub ID_AfterUpdate()
    Dim sSQL As String
    Dim rst As DAO.Recordset

    sSQL = "SELECT BarCode, [Goods Name], Unit, [Unit Price] FROM tblInventory WHERE BarCode='" & Me.ID & "'"
    Set rst = CurrentDb.OpenRecordset(sSQL)
    If rst.EOF Then
    MsgBox "New Parts"
    Me.Description.SetFocus
    Else
    Me.Description = rst(1).Value
    Me.Unit = rst(2).Value
    Me.Price = rst(3).Value
    Me.Amount.SetFocus
    End If
    rst.Close
    End Sub

    What I have tried:

    I have also noticed that if i only add 1 item it works. but does not allow another item to be input to the table. I have to close the form before it will add another item. This is an access data base i am using in access 2010, it is being developed to track inventory. I have a table that gets incoming inventory the jave takes the incoming and moves it to a table called tblinventory when i enter new item it does what it is supposed to do. however if i try to enter another item that item does not make it to the tblinventory it does show on tblincoming. I also noticed that if i change my mind and close the input form for incoming i get an error 3134, the form is empty at this time.I tried to modify the code but them get error after entering every item. so went back to the initial error. when i debug it show the on the line DoCmd.RunSql (stringSQL) I have commented the line in the code.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What is the exact message of error 3134?

    Is BarCode a number type field? If not, remove the apostrophe delimiters from the Me.ID parameter which are used for text values. Date values use # as delimiter.

    You are saving aggregate data? This is usually a bad idea. Aggregate data should be calculated from raw data when needed. Review http://allenbrowne.com/AppInventory.html

    Should enclose your code in CODE tags.
    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.

  3. #3
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Error 3134 is a syntax error in an "Insert into.." SQL statement. My guess would be that you are closing the form while some of the fields are still blank. What you can do is put Debug.print stringSQL immediately before the DoCmd.RunSQL (stringSQL) line to see what the SQL causing the error looks like. It looks like a blank in Me.Amount might be the culprit.

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

Similar Threads

  1. insert getting runtime error 3134
    By vicsaccess in forum Programming
    Replies: 5
    Last Post: 12-06-2015, 09:50 PM
  2. return to empty field before closing
    By RLehrbass in forum Access
    Replies: 8
    Last Post: 08-08-2015, 05:13 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

Tags for this Thread

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