Results 1 to 4 of 4
  1. #1
    todmac is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    20

    Insert into query that just wont work.

    Hi there,


    I have tried this many different ways, and I am still getting an error that there are too few parameters, expects 2.
    Any help is greatly appreciated.

    Code:
     Private Sub Submit_Click()
    'On Error GoTo Err_Handler
    Dim StrSql As String
    Dim status As String
    Status2 = "In Progress"
    Dim Currentuser2 As String
    Currentuser2 = "John Doe"
    Dim Now2 As Date
    Now2 = Now()
    StrSql = "INSERT into CLAIMS (Claim_Number, Vendor, Bus_Type, Location, Odometer, Date_Claim_Started, Date_of_Failure, Description, Unit_Number, Date_Submitted, Amount_Claimed_Before_Taxes, Amount_Claimed_After_Taxes, Amount_Paid, Reason_for_Short_Pay, Claim_Status, Claimed_By, Parts_to_be_returned, Date_of_Parts_Shipping) values (" & Me.Claim_Number & ", " & Me.Vendor & ", " & Me.Bus_Type & ", " & Me.Location & ", " & Me.Odometer & ", #" & Now2 & "#, # " & Me.Date_of_Failure & " #, " & Me.Description & ", " & Me.Unit_Number & ", # " & Me.Date_Submitted & " #, " & Me.Amount_Claimed_Before_Taxes & ", " & Me.Amount_Claimed_After_Taxes & ", " & Me.Amount_Paid & ", " & Me.Reason_for_Short_Pay & ", '" & Status2 & "', '" & Currentuser2 & "', " & Me.Parts_to_be_returned & ", # " & Me.Date_of_Parts_Shipping & " #)"
    CurrentDb.Execute (StrSql)
    End Sub

  2. #2
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Usually, if the rest is coded correctly, that too few parameters message indicates that something in your expression is equating to NULL.

    I would check the syntax on the dates, though. I don't think there is supposed to be a space between the # and the date.

    '#11/02/2014#' not '# 11/02/2014 #'

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    status2 is not defined don't know if that's relevant

    You could try a Debug.Print strsql and comment the
    CurrentDb.Execute (StrSql)

    and see if there is anything obvious in the print.

    I agree with Dal regarding the space before the Date.

  4. #4
    todmac is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2013
    Posts
    20
    Thank you very much to you both.
    It wasn't actually the date fields, I did more experimenting with your suggestions and realized that two of the fields I was inserting into were field type: memo and that they would likely have to be defined as text. I turned "& me.Description &" into '" & me.description &"' and the same with the other one and now it works fine.
    Thanks again.

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

Similar Threads

  1. Insert statement wont work
    By todmac in forum Access
    Replies: 1
    Last Post: 09-15-2013, 05:13 PM
  2. DoCmd.MoveSize wont work
    By gbmarlysis in forum Programming
    Replies: 3
    Last Post: 03-02-2012, 06:24 PM
  3. Moved Database - Now Query wont run
    By elb1999 in forum Queries
    Replies: 3
    Last Post: 07-12-2011, 10:19 AM
  4. Access wont insert the record
    By chaitanyakvs in forum Queries
    Replies: 1
    Last Post: 03-01-2011, 10:25 AM
  5. Query and subquery wont work with combo box
    By jbg8931 in forum Queries
    Replies: 0
    Last Post: 05-09-2010, 10:24 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