Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 16th, 2007, 10:09 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old June 16th, 2007, 02:12 PM
Authorized User
 
Join Date: Mar 2007
Location: , , United Kingdom.
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


Reply With Quote
  #3 (permalink)  
Old June 17th, 2007, 06:27 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
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!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:32 AM.


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