DAO Recordset Programming Revisited

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Everyone

I'm requesting help on creating a recordset that contains specific records. Once I have the records, I want to look at a specific field in a record and then look at the previous record and grab a value. I then want to go back to the original record and place that value in a field (write it to the record). I have some code I think might work, but I get an error when I run the code. The error tells me that I am missing a parameter-- and for the life of me, I can't figure out what I'm missin

Any help would be greatly appreciated

My code is as follows

Dim dbReadings As DAO.Databas
Dim rstReadings As DAO.Recordse

Dim strSQL As Strin
Dim strSerial As Strin
Dim strEquipment As Strin
Dim PrevNum As Integer, x As Intege
Dim CurNum As Intege
('used just to try different types of OpenRecordset items
strEquipment = Forms![frmEquipmentReadings]![EquipmentID
strSQL = "SELECT * From tblMeterReadings WHERE [EquipmentID] =""" & Forms![frmEquipmentReadings]![EquipmentID]"""

Set dbReadings = CurrentDb(
Set rstReadings = dbReadings.OpenRecordset(strSQL) ---It's at this point that I get an error message "Too Few Parameters, Expect 1". I've tried using all of the openrecordset options to no avail

If someone could help me out here I'd really appreciate it.

Respectfully in your debt
Karen O.
 
Karen, it is always best if you say what line the error occurs on. *You*
know that - we do not.

The following line is missing the ampersand before the last 4 quotes:

strSQL = "SELECT * From ... ]![EquipmentID]""""
^

In addition, you have already retrieved the equipment ID into a string
variable, so there is no point in referencing the form field again. Just use
the string variable:

strSQL = "SELECT * From tblMeterReadings WHERE [EquipmentID] =""" &
strEquipment & """"

HTH,
TC


KarenO said:
Hello Everyone,

I'm requesting help on creating a recordset that contains specific
records. Once I have the records, I want to look at a specific field in a
record and then look at the previous record and grab a value. I then want
to go back to the original record and place that value in a field (write it
to the record). I have some code I think might work, but I get an error
when I run the code. The error tells me that I am missing a parameter-- and
for the life of me, I can't figure out what I'm missing
Any help would be greatly appreciated.

My code is as follows:

Dim dbReadings As DAO.Database
Dim rstReadings As DAO.Recordset

Dim strSQL As String
Dim strSerial As String
Dim strEquipment As String
Dim PrevNum As Integer, x As Integer
Dim CurNum As Integer
('used just to try different types of OpenRecordset items)
strEquipment = Forms![frmEquipmentReadings]![EquipmentID]
strSQL = "SELECT * From tblMeterReadings WHERE [EquipmentID] =""" & Forms![frmEquipmentReadings]![EquipmentID]""""

Set dbReadings = CurrentDb()
Set rstReadings = dbReadings.OpenRecordset(strSQL) ---It's at this point
that I get an error message "Too Few Parameters, Expect 1". I've tried
using all of the openrecordset options to no avail.
 
The error occurs on the set rstReading.OpenRecordSet line. I've noted that in the code with the error: Missing parameter informatio

----- TC wrote: ----

Karen, it is always best if you say what line the error occurs on. *You
know that - we do not

The following line is missing the ampersand before the last 4 quotes

strSQL = "SELECT * From ... ]![EquipmentID]"""


In addition, you have already retrieved the equipment ID into a strin
variable, so there is no point in referencing the form field again. Just us
the string variable

strSQL = "SELECT * From tblMeterReadings WHERE [EquipmentID] ="""
strEquipment & """

HTH
T


KarenO said:
Hello Everyone
records. Once I have the records, I want to look at a specific field in
record and then look at the previous record and grab a value. I then wan
to go back to the original record and place that value in a field (write i
to the record). I have some code I think might work, but I get an erro
when I run the code. The error tells me that I am missing a parameter-- an
for the life of me, I can't figure out what I'm missin
Any help would be greatly appreciated
My code is as follows
Dim dbReadings As DAO.Databas
Dim rstReadings As DAO.Recordse
Dim strSQL As Strin
Dim strSerial As Strin
Dim strEquipment As Strin
Dim PrevNum As Integer, x As Intege
Dim CurNum As Intege
('used just to try different types of OpenRecordset items
strEquipment = Forms![frmEquipmentReadings]![EquipmentID
strSQL = "SELECT * From tblMeterReadings WHERE [EquipmentID] =""" Forms![frmEquipmentReadings]![EquipmentID]"""
Set dbReadings = CurrentDb(
Set rstReadings = dbReadings.OpenRecordset(strSQL) ---It's at this point <<<<-------- here's the error
that I get an error message "Too Few Parameters, Expect 1". I've trie
using all of the openrecordset options to no avail
 
Are you sure tblMeterReadings and EquipmentID are valid table/field names?
Often I get this when I mistype one of these.--
Scott McDaniel
CS Computer Software
www.thedatabaseplace.net

KarenO said:
Hello Everyone,

I'm requesting help on creating a recordset that contains specific
records. Once I have the records, I want to look at a specific field in a
record and then look at the previous record and grab a value. I then want
to go back to the original record and place that value in a field (write it
to the record). I have some code I think might work, but I get an error
when I run the code. The error tells me that I am missing a parameter-- and
for the life of me, I can't figure out what I'm missing
Any help would be greatly appreciated.

My code is as follows:

Dim dbReadings As DAO.Database
Dim rstReadings As DAO.Recordset

Dim strSQL As String
Dim strSerial As String
Dim strEquipment As String
Dim PrevNum As Integer, x As Integer
Dim CurNum As Integer
('used just to try different types of OpenRecordset items)
strEquipment = Forms![frmEquipmentReadings]![EquipmentID]
strSQL = "SELECT * From tblMeterReadings WHERE [EquipmentID] =""" & Forms![frmEquipmentReadings]![EquipmentID]""""

Set dbReadings = CurrentDb()
Set rstReadings = dbReadings.OpenRecordset(strSQL) ---It's at this point
that I get an error message "Too Few Parameters, Expect 1". I've tried
using all of the openrecordset options to no avail.
 
Erp! Sorry, I missed it. But the error that I pointed out, will definitely
cause your SQL to fail. Have you tried the change I suggested?

HTH,
TC


KarenO said:
The error occurs on the set rstReading.OpenRecordSet line. I've noted
that in the code with the error: Missing parameter information
----- TC wrote: -----

Karen, it is always best if you say what line the error occurs on. *You*
know that - we do not.

The following line is missing the ampersand before the last 4 quotes:

strSQL = "SELECT * From ... ]![EquipmentID]""""
^

In addition, you have already retrieved the equipment ID into a string
variable, so there is no point in referencing the form field again. Just use
the string variable:

strSQL = "SELECT * From tblMeterReadings WHERE [EquipmentID] =""" &
strEquipment & """"

HTH,
TC


KarenO said:
Hello Everyone,
records. Once I have the records, I want to look at a specific field in a
record and then look at the previous record and grab a value. I then want
to go back to the original record and place that value in a field (write it
to the record). I have some code I think might work, but I get an error
when I run the code. The error tells me that I am missing a parameter-- and
for the life of me, I can't figure out what I'm missing
Any help would be greatly appreciated.
My code is as follows:
Dim dbReadings As DAO.Database
Dim rstReadings As DAO.Recordset
Dim strSQL As String
Dim strSerial As String
Dim strEquipment As String
Dim PrevNum As Integer, x As Integer
Dim CurNum As Integer
('used just to try different types of OpenRecordset items)
strEquipment = Forms![frmEquipmentReadings]![EquipmentID]
strSQL = "SELECT * From tblMeterReadings WHERE [EquipmentID] =""" & Forms![frmEquipmentReadings]![EquipmentID]""""
Set dbReadings = CurrentDb()
Set rstReadings = dbReadings.OpenRecordset(strSQL) ---It's at this
point <<<<-------- here's the error!
 
Back
Top