By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,839 Members | 2,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,839 IT Pros & Developers. It's quick & easy.

OpenRecordset problem

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.