Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2007, 10:09 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL runtime error 3061

I have the below code that seems to work up to the SQL, the problem i am having is that apparently i do not have enough parameters yet i do not have the problem until i try and include the ActionTakenBy which is when i recieve the 3061 error.

I added a msgbox to show me what the SQL string looked like and all the fields where shown which is why nothing is making sense.

Any help would be great!!

Dim sSql1 As String
    iActionTaken = ActionTaken(varWarrantDate, [Warrant Letter Sent], LA_WARRANT_ARRANGED, LA_WARRANT_DATE_DELETED, LA_WARRANT_DATE_CHANGED)
    If (iActionTaken = LA_NONE) Then
        iActionTaken = ActionTaken(varEuroLtrDate, [Euro Letter Sent], LA_EURO_LTR_ARRANGED, LA_EURO_LTR_DATE_DELETED, LA_EURO_LTR_DATE_CHANGED)
    End If
    If (iActionTaken = LA_NONE) Then
        iActionTaken = ActionTaken(varSecondLtrDate, [2nd Letter Sent], LA_2ND_LTR_SENT, LA_2ND_LTR_DATE_DELETED, LA_2ND_LTR_DATE_CHANGED)
    End If
    If (iActionTaken = LA_NONE) Then
        iActionTaken = ActionTaken(varFirstLtrDate, [1st Letter Sent], LA_1ST_LTR_SENT, LA_1ST_LTR_DATE_DELETED, LA_1ST_LTR_DATE_CHANGED)
    End If

    If iActionTaken > 0 Then
    sSql1 = "INSERT INTO [Worked History](MPAN,ActionTaken,ActionTakenBy)" _
    & "VALUES (" & Me.MPAN & "," & iActionTaken & "," & Me.Assigned_To & ");"
    MsgBox sSql1
    CurrentDb.Execute sSql1
    End If

 
Old June 16th, 2007, 02:12 PM
Authorized User
 
Join Date: Mar 2007
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's not possible to tell from the snippet of code you have supplied, but it is likely that one or more of the items you are including in your VALUES clause are strings - no idea about MPAN, iActionTaken looks like it might be integer, but Assigned_To is probably going to need some kind of text. In that case, you need to include some kind of delimiter around the string elements.

For example, your SQL would currently look something like this:

INSERT INTO [Worked History](MPAN,ActionTaken,ActionTakenBy)VALUES (3,1,Fred Smith);

It should look more like this:

INSERT INTO [Worked History] (MPAN, ActionTaken, ActionTakenBy) VALUES (3, 1, "Fred Smith");

Note the extra spaces throughout - some are essential, some are just for readability - and the delimiters around the string. To include a double quote in a literal string, you need to double it up, as in ...

Dim strQuote as String
strQuote = """"

... which ends up setting the variable to just *one* double quote character.

Hope you can follow all this, and good luck!

Richard


 
Old June 17th, 2007, 06:27 AM
Registered User
 
Join Date: Jun 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Richard you are officially a ledgend!! after nearly a week it finally works!! thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
hi i got runtime error 13 Type Mismatch error sriharsha345 Access VBA 2 February 21st, 2008 09:30 AM
runtime error 20599 cannot open sql server francitaj Crystal Reports 3 October 4th, 2007 05:27 AM
sql help got Microsoft VBScript runtime error '800 marky1216 Classic ASP Databases 0 December 9th, 2005 12:45 AM
Runtime Error 3061 - too few parameters Raymie_C Access VBA 14 July 18th, 2005 04:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.