Results 1 to 3 of 3
  1. #1
    Damo10 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    11

    Insert Into code issue

    All,



    I have the following macro to insert data into a table but it is coming up with an run time error 3421 - data type conversion error.
    Can anyone please tell me what is wrong with the code?


    The SealType & Seal fields are Text and the Quantity & Qty are Number

    Code:
    Private Sub Machine_AfterUpdate()
    Dim i As Integer
    Dim Qty As Integer
    Dim Seal As String
    
    For i = 1 To 10
        If (DLookup("Seal" & i, "SealQtyQry")) <> vbNullString Then
            Seal = DLookup("Seal" & i, "SealQtyQry")
            Qty = DLookup("Seal" & i & "Qty", "SealQtyQry")
            
            CurrentDb.Execute "INSERT INTO SealStripDetail (SealType,Quantity) VALUES (Seal & ", " & Qty)"
            
        End If
    Next i
    End Sub

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    think this should be

    "INSERT INTO SealStripDetail (SealType,Quantity) VALUES ('" & Seal & "', " & Qty & ")"

  3. #3
    Damo10 is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2012
    Posts
    11
    Great, thanks

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

Similar Threads

  1. INSERT INTO code not working properly.
    By Alphix in forum Forms
    Replies: 8
    Last Post: 11-12-2014, 04:10 PM
  2. Replies: 22
    Last Post: 05-21-2013, 07:54 PM
  3. VB Code for INSERT INTO
    By StephenVW in forum Programming
    Replies: 10
    Last Post: 03-25-2013, 08:07 AM
  4. Problem with INSERT INTO query code
    By rghollenbeck in forum Queries
    Replies: 8
    Last Post: 09-27-2011, 12:16 PM
  5. Forgot how to insert Code in a Thread
    By RAPSR in forum Programming
    Replies: 1
    Last Post: 10-11-2010, 10:04 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