Results 1 to 3 of 3
  1. #1
    Eranka is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Posts
    150

    Argument Not Optional

    Hi guys

    Code:
    CurrentDb.Execute = "INSERT INTO Paper_Marking (Lecturer_ID,Unit_ID,No_Of_Papers,Semester_ID) " & "VALUES ('" & Me.Combo2 & "','" & Me.Combo5 & "','" & Me.Text11 & "','" & Me.Text8 & "')"
    When i run the above insert statement, i get Argument Not Optional error, Appreciate your help on this.


    Thanks in Advance

  2. #2
    Minty is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,157
    From the field names I would guess that all of those values are numbers, but you are trying to insert the combo values as text items ?

    If my guess is correct remove all the ' ' around your combo concatenated values.

    Edit: Form your string as a variable to assist debugging as well;

    Code:
    Dim sSql as string 
    
    sSql = "INSERT INTO Paper_Marking (Lecturer_ID,Unit_ID,No_Of_Papers,Semester_ID) VALUES ('" & Me.Combo2 & "','" & Me.Combo5 & "','" & Me.Text11 & "','" & Me.Text8 & "')"
    
    Debug.Print sSql
    
    Currentdb.Execute sSql
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  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,652
    Minty's suggestions are good. The error is because the "=" after Execute needs to be deleted:

    Quote Originally Posted by Eranka View Post
    Code:
    CurrentDb.Execute = "INSERT ..."
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Argument not optional.
    By Homegrownandy in forum Programming
    Replies: 4
    Last Post: 05-11-2017, 03:23 AM
  2. Replies: 5
    Last Post: 02-28-2017, 09:57 PM
  3. Optional argument in function call.
    By Robeen in forum Access
    Replies: 2
    Last Post: 12-06-2016, 04:40 PM
  4. Compile Error: Argument not optional
    By Nadine67 in forum Access
    Replies: 5
    Last Post: 08-02-2015, 03:09 PM
  5. error argument not optional
    By slimjen in forum Programming
    Replies: 10
    Last Post: 03-20-2013, 09:31 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