Results 1 to 3 of 3
  1. #1
    Peter01 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2009
    Posts
    2

    Problem with DoCmd.RunSQL

    Hi there. This is my first time using a forum so please forgive me if I have posted in the wrong area. I am having issues with the below code. It used to work, and now suddenly it won't. I have checked with out IT department and there were no upgrades or changes made last night to our systems. What this code does is take information from text boxes on a form and add them to an existing table:

    Dim strSQL As String
    strSQL = "INSERT INTO Tbl_ClosedActivities (ActivityNumber, Goal, CorporateDivisionalPriorities, InitiativesActivities, KeyOutcomes, FunctionalArea, Strategy, Approver, Owner, ActionsTaken, DocumentumHyperlink, Comments, FirstDueDate, Frequency, DateClosed) VALUES ('" & ActivityNumber.Value & "', '" & Goal.Value & "', '" & CorporateDivisionalPriorities.Value & "', '" & InitiativesActivities.Value & "', '" & KeyOutcomes.Value & "', '" & FunctionalArea.Value & "', '" & Strategy.Value & "', '" & Approver.Value & "', '" & Owner.Value & "','" & ActionsTaken.Value & "', '" & DocumentumHyperlink.Value & "', '" & Comments.Value & "', #" & FirstDueDate.Value & "#, '" & Frequency.Value & "', =(Now))"


    DoCmd.RunSQL strSQL

    It now comes up with syntax error 3075 when I attempt to run it. I have been over the code again and again and cannot find issue with it. Is anyone able to help or offer advice?

    Thanks in advance, Pete

  2. #2
    dcrake's Avatar
    dcrake is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Aug 2009
    Posts
    435
    Just before you issue the
    DoCmd.RunSQL command
    insert Debug.Print strSQL.
    Put a breakpoint on this line.
    run the form when the strSQL is sent to the immediate window
    copy the resulting code onto the clipboard.
    Cancel the code to close the form.
    Go to queries > add new.
    Don't select any tables/queries, switch to SQL view
    Paste the clipboard contets into the SQL pane
    Switch to Design view

    If any errors exist Access will let you know and attempt to show you where by positioning the cursor at that point.

    It may be due to null values in your query or missing parameters or invalid characters, such as apostophies in strings. It's a case of trial and error.

    David

  3. #3
    Peter01 is offline Novice
    Windows XP Access 2003
    Join Date
    Sep 2009
    Posts
    2
    Hi David, thankyou for your help. The problem has been sorted out now.

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

Similar Threads

  1. Can docmd.openreport print X copies on Y printer?
    By Coolpapabell in forum Reports
    Replies: 1
    Last Post: 09-02-2009, 08:35 AM
  2. docmd.runsql not working
    By Rameez in forum Programming
    Replies: 3
    Last Post: 08-07-2009, 10:07 AM
  3. Issues with DoCmd.GoToControl
    By RaMcHiP in forum Programming
    Replies: 1
    Last Post: 05-09-2009, 08:56 PM
  4. DoCmd.OpenForm Modification
    By alsoto in forum Forms
    Replies: 6
    Last Post: 05-01-2009, 07:28 AM
  5. DoCmd.SendObject Help
    By bgreer5050 in forum Programming
    Replies: 0
    Last Post: 01-12-2007, 06:27 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