473,785 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OpenRecordset problem

The code below is pretty straight forward. But I am having a problem
adding with the Set rs1 statement. I keep getting a "Too Few
Parameters - Expected 1" error. What I've added --and whatI suspect is
causing problems-- is the parameter "intPONumbe r". I'm sure it's the
formatting of the SQL string.

Any help would be greatly appreciated. TIA!
CODE
----------------------------------------------
Private Sub cmdDelete_Click ()

Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset
Dim VbMsgBoxResult As Integer
Dim varPOBaseNumber As String
Dim intPONumber As Integer

VbMsgBoxResult = MsgBox("Are you sure you want to delete this Purchase
Order?", vbYesNo, "Caution")

If VbMsgBoxResult = vbYes Then

Set db1 = CurrentDb()
varPOBaseNumber = POBaseNumber
intPONumber = PONumber

Set rs1 = db1.OpenRecords et("SELECT tblPrecisionPur chaseOrders.* FROM
tblPrecisionPur chaseOrders WHERE
tblPrecisionPur chaseOrders.PON umber=intPONumb er
AND(((tblPrecis ionPurchaseOrde rs.POBaseNumber )=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)

Do Until rs1.EOF
'rs1.Delete
rs1.Move 1
Loop

db1.Close
Set db1 = Nothing
rs1.Close
Set rs1 = Nothing

DoCmd.Requery
End If
End Sub
Nov 13 '05 #1
2 2345
Change this line:

Set rs1 = db1.OpenRecords et("SELECT tblPrecisionPur chaseOrders.* FROM
tblPrecisionPur chaseOrders WHERE
tblPrecisionPur chaseOrders.PON umber=intPONumb er
AND(((tblPrecis ionPurchaseOrde rs.POBaseNumber )=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)
to this:

Set rs1 = db1.OpenRecords et("SELECT tblPrecisionPur chaseOrders.* FROM
tblPrecisionPur chaseOrders WHERE
tblPrecisionPur chaseOrders.PON umber=" & intPONumber & "
AND(((tblPrecis ionPurchaseOrde rs.POBaseNumber )=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)
--

Ken Snell
<MS ACCESS MVP>

"JumpinJeff " <Ju********@gma il.com> wrote in message
news:92******** *************** ***@posting.goo gle.com...
The code below is pretty straight forward. But I am having a problem
adding with the Set rs1 statement. I keep getting a "Too Few
Parameters - Expected 1" error. What I've added --and whatI suspect is
causing problems-- is the parameter "intPONumbe r". I'm sure it's the
formatting of the SQL string.

Any help would be greatly appreciated. TIA!
CODE
----------------------------------------------
Private Sub cmdDelete_Click ()

Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset
Dim VbMsgBoxResult As Integer
Dim varPOBaseNumber As String
Dim intPONumber As Integer

VbMsgBoxResult = MsgBox("Are you sure you want to delete this Purchase
Order?", vbYesNo, "Caution")

If VbMsgBoxResult = vbYes Then

Set db1 = CurrentDb()
varPOBaseNumber = POBaseNumber
intPONumber = PONumber

Set rs1 = db1.OpenRecords et("SELECT tblPrecisionPur chaseOrders.* FROM
tblPrecisionPur chaseOrders WHERE
tblPrecisionPur chaseOrders.PON umber=intPONumb er
AND(((tblPrecis ionPurchaseOrde rs.POBaseNumber )=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)

Do Until rs1.EOF
'rs1.Delete
rs1.Move 1
Loop

db1.Close
Set db1 = Nothing
rs1.Close
Set rs1 = Nothing

DoCmd.Requery
End If
End Sub

Nov 13 '05 #2
Worked like a champ. Thanks a bunch!

"Ken Snell" <kt***********@ ncoomcastt.rena etl> wrote in message news:<Ts******* *************@c omcast.com>...
Change this line:

Set rs1 = db1.OpenRecords et("SELECT tblPrecisionPur chaseOrders.* FROM
tblPrecisionPur chaseOrders WHERE
tblPrecisionPur chaseOrders.PON umber=intPONumb er
AND(((tblPrecis ionPurchaseOrde rs.POBaseNumber )=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)
to this:

Set rs1 = db1.OpenRecords et("SELECT tblPrecisionPur chaseOrders.* FROM
tblPrecisionPur chaseOrders WHERE
tblPrecisionPur chaseOrders.PON umber=" & intPONumber & "
AND(((tblPrecis ionPurchaseOrde rs.POBaseNumber )=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)
--

Ken Snell
<MS ACCESS MVP>

"JumpinJeff " <Ju********@gma il.com> wrote in message
news:92******** *************** ***@posting.goo gle.com...
The code below is pretty straight forward. But I am having a problem
adding with the Set rs1 statement. I keep getting a "Too Few
Parameters - Expected 1" error. What I've added --and whatI suspect is
causing problems-- is the parameter "intPONumbe r". I'm sure it's the
formatting of the SQL string.

Any help would be greatly appreciated. TIA!
CODE
----------------------------------------------
Private Sub cmdDelete_Click ()

Dim db1 As DAO.Database
Dim rs1 As DAO.Recordset
Dim VbMsgBoxResult As Integer
Dim varPOBaseNumber As String
Dim intPONumber As Integer

VbMsgBoxResult = MsgBox("Are you sure you want to delete this Purchase
Order?", vbYesNo, "Caution")

If VbMsgBoxResult = vbYes Then

Set db1 = CurrentDb()
varPOBaseNumber = POBaseNumber
intPONumber = PONumber

Set rs1 = db1.OpenRecords et("SELECT tblPrecisionPur chaseOrders.* FROM
tblPrecisionPur chaseOrders WHERE
tblPrecisionPur chaseOrders.PON umber=intPONumb er
AND(((tblPrecis ionPurchaseOrde rs.POBaseNumber )=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)

Do Until rs1.EOF
'rs1.Delete
rs1.Move 1
Loop

db1.Close
Set db1 = Nothing
rs1.Close
Set rs1 = Nothing

DoCmd.Requery
End If
End Sub

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
4815
by: Russell Potter | last post by:
I'm trying to create a recordset using "currentDB.OpenRecordSet", using a query as the "source" string (the only parameter: so all the others are set to their defaults which, I believe, means the recordset returned will be a "table" one), but VB keeps giving me "type mismatch" errors. Should this problem be resolved by changing the "options" parameter so that a compatible recordset will be returned, thus eliminating the error? Thanks,
1
2169
by: Cristina V | last post by:
Hi! I have a problem with this procedure. When I compile it Access do the next error: "error 13.not the types coincide" in the line of the "openrecordset". I don't understand wich is the problem, because I have done many sub as this. I supose the problem is the references. But I think I have all the
9
5388
by: MLH | last post by:
A runtime error 13 (type mismatch) occurs running the following line: Set rst = dbs.OpenRecordset("tblMyTable", dbOpenTable) What would be the most likely place I would find the source of the error? The DAO code lines providing dependencies to this one are... Dim dbs As Database, rst as RecordSet Set dbs = CurrentDb
2
1923
by: MLH | last post by:
Set rstOtherTable = MyDB.OpenRecordset(xxx, dbOpenDynaset) I have a question regarding syntax of the above OpenRecordset method: Is it OK for xxx to reference both tables and queries when using dbOpenDynaset? And how about these 2 lines together - is the code structure OK? xxx = "SELECT tblLienHolders.LienHolderID FROM tblLienHolders;" Set rstOtherTable = MyDB.OpenRecordset(xxx, dbOpenDynaset)
18
5096
by: Shawn Yates | last post by:
I have a report that looks up the earliest start time in a query . Right now it opens up the query and grabs the earliest start date like it should. This is the working code: Set rs = db.OpenRecordset("SELECT Min() AS MinOfStartTime " _ & " FROM Assignments", dbOpenSnapshot) The problem is that this query is showing start and finish times from different events. Is there a way to have it grab the earliest start
1
1713
by: peridian | last post by:
Hello, Used these boards a few times before to find answers, wondered if somebody could help me out. (Using Access 2000, and DAO Reference Library). I have some code which used TransferText to link a series of Text files into the database. I then called a function which ran some validation through the entries imported by calling OpenRecordset with an SQL query to access the linked files (nothing complex, just a SELECT * FROM TableName...
10
3742
by: MLH | last post by:
Gentlemen: I am having one heck of a time taking a DAO walk through the records in an SQL dynaset. I'm trying to walk a set of records returned by a UNION query. I'm attempting to filter the records to those related to vehicle #60 ( = 60 ). If I explicitly specify 60 in the SQL ==everything works fine. Take a look: 100 PString = "SELECT & " & Chr$(&H22) & Space(1) & Chr$(&H22) & " & AS Recipient " 120 PString = PString & "FROM...
22
10296
by: MLH | last post by:
100 Dim db As Database, rst As Recordset 120 Set db = CurrentDb 140 PString = "SELECT qryBatchList.ReadyFor906, qryBatchList.BatchID FROM qryBatchList WHERE qryBatchList.BatchID=GetCurrentBatchID()" 160 Set rst = db.OpenRecordset(PString, dbOpenDynaset) At compile time, things are OK. But at run time, line #160 gives rise to an error saying some FN I've used for years is undefined. It almost seems like it pukes on some random
7
11058
by: mirandacascade | last post by:
The questions are toward the bottom of this post. Situation is this: 1) Access 97 2) Multi-user appplication 3) SQL Server 2000 4) Sporadically (i.e. less than 1% of the time) encounter the following error: 3218 Couldn't update; currently locked
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10151
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3647
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.