A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

error 3061 with insert into sql



 
 
Thread Tools Display Modes
  #1  
Old December 18th, 2009, 02:56 PM posted to microsoft.public.access.queries
chanu
external usenet poster
 
Posts: 17
Default error 3061 with insert into sql

i have the following function.
Public Function sqltest( )
Dim strSQL As String
strSQL = "INSERT INTO [tblEmpOldDA] " & _
"SELECT 1 AS EmpSerialID ," & _
"[tblOldDA].FromDate ," & _
"[tblOldDA].ToDate ," & _
"[tblOldDA].Rate " & _
"FROM [tblOldDA] "
CurrentDb.Execute strSQL
End Function
when i use this query it is throwing runtime error 3061 too few parameters.
Expected 1
when i tried this with docomd.runsql, it is asking me for RATE parameter.
Actually i am creating tblEmpOldDA as a duplicate table of tblOldDA with
EmpSerialID as an extra field. Why is it not working? I have already asked a
question about creating a duplicate table two days ago but i found no answer
from this forum. So, friends if at all i am unclear in representing the
problem, pl. ask me follow-up question to make yourself clear about it . but
don't ignore it please. I will be hopeful of your reply
--
from
chanakya
Baruva
  #2  
Old December 18th, 2009, 07:23 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default error 3061 with insert into sql

chanu wrote:

i have the following function.
Public Function sqltest( )
Dim strSQL As String
strSQL = "INSERT INTO [tblEmpOldDA] " & _
"SELECT 1 AS EmpSerialID ," & _
"[tblOldDA].FromDate ," & _
"[tblOldDA].ToDate ," & _
"[tblOldDA].Rate " & _
"FROM [tblOldDA] "
CurrentDb.Execute strSQL
End Function
when i use this query it is throwing runtime error 3061 too few parameters.
Expected 1
when i tried this with docomd.runsql, it is asking me for RATE parameter.



That error means that the field Rate does not exist in
tblOldDA. Are you sure you spelled it correctly?

What do you want the 1 AS EmpSerialID in every record to do?
Whatever it is, I don't see how a constant can do it.

--
Marsh
MVP [MS Access]
  #3  
Old December 19th, 2009, 04:40 PM posted to microsoft.public.access.queries
chanu
external usenet poster
 
Posts: 17
Default error 3061 with insert into sql

Hai Marsh,
you are right that i've spelled it wrong. the field name is not Rate but
DArate. Thanks a lot. i actually don't want '1' all the time but i want to
replace with the primary ID of the mainform. The idea is to create a
duplicate of the default table[tblOldDA] and bind it with the an employee by
assigning his ID to it. could you help me how to replace it with the Main
form's recordset primaryID.
--
from
chanakya
Baruva



  #4  
Old December 19th, 2009, 04:49 PM posted to microsoft.public.access.queries
chanu
external usenet poster
 
Posts: 17
Default error 3061 with insert into sql

one more doubt please!
is there any way to check that the records are added. Pl. excuse me because
i am posting this as a postscript
--
from
chanakya
Baruva



  #5  
Old December 19th, 2009, 06:37 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default error 3061 with insert into sql

chanu wrote:
you are right that i've spelled it wrong. the field name is not Rate but
DArate. Thanks a lot. i actually don't want '1' all the time but i want to
replace with the primary ID of the mainform. The idea is to create a
duplicate of the default table[tblOldDA] and bind it with the an employee by
assigning his ID to it. could you help me how to replace it with the Main
form's recordset primaryID.



I do not understand what you mean by "replace it with the
Main form's recordset primaryID".

Taking a stab in the dark I would guess something like:

strSQL = "INSERT INTO [tblEmpOldDA] " & _
"SELECT " & Me.[primary key field] & " AS EmpSerialID," &
_
"[tblOldDA].FromDate ," & _
"[tblOldDA].ToDate ," & _
"[tblOldDA].Rate " & _
"FROM [tblOldDA] "

BUT, that will copy every record in tblOldDA, I strongly
suspect that you should have a WHERE clause to select only
one record. Normally, the criteria would be the primary key
field, but you said that doesn't exist in tblOldDA???
--
Marsh
MVP [MS Access]
  #6  
Old December 19th, 2009, 06:48 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default error 3061 with insert into sql

chanu wrote:
is there any way to check that the records are added.



You can get the number of records that were added by using
the RecordsAffected property.

Dim db As Database
Set db = CurrentDb()
db.Execute strSQL
MsgBox db.RecordsAffected & " records were added."

Note that you can not use CurrentDb.Execute because
CurrentDb is recreated every time you use it.
(RecordsAffected would not be set in the new instance of
CurrentDb)
--
Marsh
MVP [MS Access]
  #7  
Old December 23rd, 2009, 05:48 PM posted to microsoft.public.access.queries
Access infant
external usenet poster
 
Posts: 14
Default error 3061 with insert into sql

Thanks Marsh
because of my unfamiliarity with the technical terms, i could not express
myself. but what you guessed is right. i want to fill all the records with
only one primary ID. Thanks a lot
--
from
chanakya
Baruva



 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:43 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.