473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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 "intPONumber". 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.OpenRecordset("SELECT tblPrecisionPurchaseOrders.* FROM
tblPrecisionPurchaseOrders WHERE
tblPrecisionPurchaseOrders.PONumber=intPONumber
AND(((tblPrecisionPurchaseOrders.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 2331
Change this line:

Set rs1 = db1.OpenRecordset("SELECT tblPrecisionPurchaseOrders.* FROM
tblPrecisionPurchaseOrders WHERE
tblPrecisionPurchaseOrders.PONumber=intPONumber
AND(((tblPrecisionPurchaseOrders.POBaseNumber)=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)
to this:

Set rs1 = db1.OpenRecordset("SELECT tblPrecisionPurchaseOrders.* FROM
tblPrecisionPurchaseOrders WHERE
tblPrecisionPurchaseOrders.PONumber=" & intPONumber & "
AND(((tblPrecisionPurchaseOrders.POBaseNumber)=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)
--

Ken Snell
<MS ACCESS MVP>

"JumpinJeff" <Ju********@gmail.com> wrote in message
news:92**************************@posting.google.c om...
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 "intPONumber". 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.OpenRecordset("SELECT tblPrecisionPurchaseOrders.* FROM
tblPrecisionPurchaseOrders WHERE
tblPrecisionPurchaseOrders.PONumber=intPONumber
AND(((tblPrecisionPurchaseOrders.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.renaetl> wrote in message news:<Ts********************@comcast.com>...
Change this line:

Set rs1 = db1.OpenRecordset("SELECT tblPrecisionPurchaseOrders.* FROM
tblPrecisionPurchaseOrders WHERE
tblPrecisionPurchaseOrders.PONumber=intPONumber
AND(((tblPrecisionPurchaseOrders.POBaseNumber)=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)
to this:

Set rs1 = db1.OpenRecordset("SELECT tblPrecisionPurchaseOrders.* FROM
tblPrecisionPurchaseOrders WHERE
tblPrecisionPurchaseOrders.PONumber=" & intPONumber & "
AND(((tblPrecisionPurchaseOrders.POBaseNumber)=" & Qu &
varPOBaseNumber & Qu & "))", dbOpenSnapshot)
--

Ken Snell
<MS ACCESS MVP>

"JumpinJeff" <Ju********@gmail.com> wrote in message
news:92**************************@posting.google.c om...
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 "intPONumber". 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.OpenRecordset("SELECT tblPrecisionPurchaseOrders.* FROM
tblPrecisionPurchaseOrders WHERE
tblPrecisionPurchaseOrders.PONumber=intPONumber
AND(((tblPrecisionPurchaseOrders.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
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...
1
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...
9
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...
2
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...
18
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 =...
1
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...
10
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...
22
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...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.