UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Run-time error 3061 with OpenRecordset    
 
   
missy
post Jan 15 2006, 11:31 PM
Post#1



Posts: 4
Joined: 15-January 06



Hi,
just joined this forum today and found everyone quite helpful... =)
I'm hoping this is a common error that someone can also help me with...=/
I have in VB:
CODE
With rNZEPData
  sSQL = "SELECT Date, TrimmedTicker, Name, SEDOL, Price "
  sSQL = sSQL & "FROM [tblNZBarraTickerLookup] "
  sSQL = sSQL & "WHERE ([Date] = #" & Format(dDate, "mm/dd/yyyy") & "#) AND ([TrimmedTicker] = " & !BarraNZSXCode & ")"
  Set rBarraData = CurrentDb.OpenRecordset(sSQL, dbOpenSnapshot)
End With

(where rNZEP is a DAO.RecordSet)
The error I get is: Run-time error '3061': Too few parameters. Expected 1
It works fine without the extra AND statement
i.e. its ok when I just have
sSQL = sSQL & "WHERE ([Date] = #" & Format(dDate, "mm/dd/yyyy") & "#)"
Solutions???
Thanks heaps
Go to the top of the page
 
HiTechCoach
post Jan 15 2006, 11:38 PM
Post#2


UtterAccess VIP
Posts: 19,008
Joined: 29-September 03
From: Oklahoma City, Oklahoma


Welcome to Utter Access!

What data type is TrimmedTicker?


Note that you have field names that as reserved words. This should be avoided. It helps to always wrap them with [] so that Access does not get confused.
Go to the top of the page
 
missy
post Jan 15 2006, 11:40 PM
Post#3



Posts: 4
Joined: 15-January 06



Hi
It's text...
Go to the top of the page
 
R. Hicks
post Jan 15 2006, 11:53 PM
Post#4


UA Forum Administrator
Posts: 40,467
Joined: 8-February 00
From: Birmingham, Alabama USA


Welcome to Utter Access Forums ... frown.gif

Couple of things here ...
First .. "Date" and "Name" are both Reserved Words in Access and should not be used in the naming of objects in your application ...
Orecommend that you alter the name of these fields to a legal name ....

Now for your syntax in your code ...
Try altering your code to the following:

CODE
With rNZEPData
nbsp; sSQL = "SELECT [Date], TrimmedTicker, [Name], SEDOL, Price " & _
   "FROM [tblNZBarraTickerLookup] " & _
   "WHERE [Date] = #" & Format(dDate, "mm/dd/yyyy") & "# " & _
   "AND [TrimmedTicker] = '" & !BarraNZSXCode & "';"
  Set rBarraData = CurrentDb.OpenRecordset(sSQL, dbOpenSnapshot)
End With

RDH
Go to the top of the page
 
missy
post Jan 16 2006, 12:01 AM
Post#5



Posts: 4
Joined: 15-January 06



O my gosh!!
hankyou!! You don't know how happy you've made me!!
yayhandclap.gif
Go to the top of the page
 
R. Hicks
post Jan 16 2006, 12:07 AM
Post#6


UA Forum Administrator
Posts: 40,467
Joined: 8-February 00
From: Birmingham, Alabama USA


Boyd found the problem ... I just followed up with the altered, needed syntax ...
Also .. you need to alter the field names as I replied .. using reserved words and illegal characters in an application can create many problems that can be very hard to find later on in the developement of this application ...
DH
Go to the top of the page
 
missy
post Jan 16 2006, 12:08 AM
Post#7



Posts: 4
Joined: 15-January 06



Thanks to you both...!!!
I'll start cleaning up my code now... o!
Go to the top of the page
 
R. Hicks
post Jan 16 2006, 12:09 AM
Post#8


UA Forum Administrator
Posts: 40,467
Joined: 8-February 00
From: Birmingham, Alabama USA


You are very welcome .. wink.gif
DH
Go to the top of the page
 
HiTechCoach
post Jan 16 2006, 02:57 PM
Post#9


UtterAccess VIP
Posts: 19,008
Joined: 29-September 03
From: Oklahoma City, Oklahoma


You're welcome.
Glad we could assist.
uarulez2.gif
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    22nd October 2018 - 06:49 PM