R
RiceFarmer via AccessMonster.com
From a combobox on a form, iI am trying to access a record in another table.
I am using the afterupdate event of the tw combobox to create a query to
find the recordset. I will then use the fields in the recordset to perform
calsulations. I can't figure out how to look up a recordset. I keep getting
an error 3061 "too few parameters" when I go to the module to look up the
recordset. I know this is so simple...I hate to show my ignorance. Here is
the code.
Private Sub TW_AfterUpdate()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim sTW1 As Single
Dim sTW2 As Single
Dim sTW3 As Single
Dim sTW4 As Single
Dim sTW5 As Single
Dim sTW6 As Single
Dim sTW7 As Single
Dim sTW8 As Single
Dim intElevatorID As Integer
Dim intCropID As Integer
intElevatorID = Me.cboElevatorID.Value
Debug.Print intElevatorID
intCropID = Me.cboCropID.Value
Dim curTW12 As Currency
Set dbs = CurrentDb
Debug.Print dbs.Name
Set qdf = dbs.QueryDefs("qryGrainDiscounts")
It works to this point, but I've tried the next two lines, and neither works.
This is where I get my parameter error. I need something like the second
line that looks up a recordset based on the values in two different
comboboxes located on the form. The first line is commented out so i could
try the second line. Both give the same error.
'Set rst = qdf.OpenRecordset()
Set rst = dbs.OpenRecordset("SELECT tblGrainDiscountSchedule.* FROM
tblGrainDiscountSchedule WHERE (((tblGrainDiscountSchedule.ElevatorID)=[forms]
![frmWeightTickets]![cboElevatorID]) AND ((tblGrainDiscountSchedule.CropID)=
[forms]![frmWeightTickets]![cboCropID]));")
I have tried putting the values of the comboboxes into variables, and tried
refencing the comboboxes from the code.
I hope this is enough info. Is there a simpler way of doing this? Thanks.
I am using the afterupdate event of the tw combobox to create a query to
find the recordset. I will then use the fields in the recordset to perform
calsulations. I can't figure out how to look up a recordset. I keep getting
an error 3061 "too few parameters" when I go to the module to look up the
recordset. I know this is so simple...I hate to show my ignorance. Here is
the code.
Private Sub TW_AfterUpdate()
Dim dbs As DAO.Database
Dim qdf As DAO.QueryDef
Dim rst As DAO.Recordset
Dim sTW1 As Single
Dim sTW2 As Single
Dim sTW3 As Single
Dim sTW4 As Single
Dim sTW5 As Single
Dim sTW6 As Single
Dim sTW7 As Single
Dim sTW8 As Single
Dim intElevatorID As Integer
Dim intCropID As Integer
intElevatorID = Me.cboElevatorID.Value
Debug.Print intElevatorID
intCropID = Me.cboCropID.Value
Dim curTW12 As Currency
Set dbs = CurrentDb
Debug.Print dbs.Name
Set qdf = dbs.QueryDefs("qryGrainDiscounts")
It works to this point, but I've tried the next two lines, and neither works.
This is where I get my parameter error. I need something like the second
line that looks up a recordset based on the values in two different
comboboxes located on the form. The first line is commented out so i could
try the second line. Both give the same error.
'Set rst = qdf.OpenRecordset()
Set rst = dbs.OpenRecordset("SELECT tblGrainDiscountSchedule.* FROM
tblGrainDiscountSchedule WHERE (((tblGrainDiscountSchedule.ElevatorID)=[forms]
![frmWeightTickets]![cboElevatorID]) AND ((tblGrainDiscountSchedule.CropID)=
[forms]![frmWeightTickets]![cboCropID]));")
I have tried putting the values of the comboboxes into variables, and tried
refencing the comboboxes from the code.
I hope this is enough info. Is there a simpler way of doing this? Thanks.