Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 May 23rd, 2006, 07:47 AM
Authorized User
 
Join Date: May 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Getting a Run-Time Error with this code..

Hey guys, I'm kinda new to the whole programming with VBA on Access..since I'm just finishing up college and all and doing some database manipulation for a summer job, anyway on to the problem..

We're trying to have one of our databases update another database with some information that is contained on both databases. Now, when I do this, I get a Run-Time Error 3061 'Tew Few Paramters: Expected 1' Below is the code that I've been using for this part of the form.

Dim rs As DAO.Recordset
Dim sqlSI As String
Dim Sign As Variant
Dim updateRec As DAO.Recordset
Dim updateSQL As String
Dim qryData As Variant
    

sqlSI = "SELECT ([SERVICE RECORDS2].[Service Record])FROM [SERVICE RECORDS2]WHERE [SERVICE RECORDS2].[Service Report #]=" & Me.[Service_Report__] & ";"


Set rs = CurrentDb.OpenRecordset(sqlSI) - This is where I get the error.
Set Sign = rs
MsgBox rs.RecordCount

If rs.RecordCount = 0 Then
    'Set updateSQL = dbsCurrent.QueryDefs("QRYSErvice")
    updateSQL = "INSERT INTO [Service Records2] ( [Service Report #], ServiceDate, EmployeeID, Description, ContactID, ProjectID, [Dash #], [Service Type], [Test Speed], [Test containers], [Fit Test], [Fit Notes], [Tech Signature], [Customer Signature], [Work Requested], [Customer Comments], [Static Speed], [Jog Speed], [Line Speed], [N/A For Speed], [No Containers], [Mould or Test Container], Containers, [Full Production], [N/A For Service], [Checked Loose/Tight Cont], [Out Of Time Cond], [Checked Loose/Tight Cores] )" & _
    "SELECT [Service Records].[Service Report #], [Service Records].ServiceDate, [Service Records].EmployeeID, [Service Records].Description, [Service Records].ContactID, [Service Records].ProjectID, [Service Records].[Dash #], [Service Records].[Service Type], [Service Records].[Test Speed], [Service Records].[Test containers], [Service Records].[Fit Test], [Service Records].[Fit Notes], [Service Records].[Tech Signature], [Service Records].[Customer Signature], [Service Records].[Work Requested], [Service Records].[Customer Comments], [Service Records].[Static Speed], [Service Records].[Jog Speed], [Service Records].[Line Speed], [Service Records].[N/A For Speed], [Service Records].[No Containers], [Service Records].[Mould or Test Container], [Service Records].Containers, [Service Records].[Full Production], [Service Records].[N/A For Service], [Service Records].[Checked Loose/Tight Cont], [Service Records].[Out Of Time Cond], [Service Records].[Checked Loose/Tight Cores]" & _
    "FROM [Service Records]WHERE ((([Service Records].[Service Report #])=" & Me.[Service_Report__] & "));"

    DoCmd.RunSQL updateSQL
    'Set updateRec = CurrentDb.OpenRecordset(updateSQL)
    Set qryData = updateRec
Else
    MsgBox "Record Already Exists. Please Use the f:\commom\databases\megabase"
End If
'Forms![FormName]!SignIn = Sign

Any help would be great! thanks guys
 
Old May 23rd, 2006, 09:07 AM
Authorized User
 
Join Date: May 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I added in a msgbox(sqlSI) to see what I was getting, and this is exactly what I got.

SELECT ([SERVICE RECORDS2].[Service Record])FROM [SERVICE RECORDS2]WHERE [SERVICE RECORDS2].[Service Report #]=888888;

 
Old May 28th, 2006, 07:06 PM
Authorized User
 
Join Date: Jul 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try omitting the ()

sqlSI = "SELECT [SERVICE RECORDS2].[Service Record] FROM [SERVICE RECORDS2]WHERE [SERVICE RECORDS2].[Service Report #]=" & Me.[Service_Report__] & ";"







Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
DataSet/XSD files instead of Run Time Code aesalazar Visual Basic 2005 Basics 3 May 25th, 2007 11:57 AM
run time error ashishroyk Java GUI 0 October 8th, 2004 01:42 AM
RUN-TIME ERROR compcad Beginning VB 6 2 May 21st, 2004 02:01 AM
Run-time code execution module0000 Beginning VB 6 1 June 20th, 2003 04:19 AM





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