S
stevekennedy99
Guest
I am trying to open a query as a recordset in DAO (QryMissingTimes). This query refers to another query (QryCat5_8_TotalValue) that has two fields (Hourly_Rate & Works_Overhead)that are set from a textbox on an access form. I have worked out that if I want to run this query I have to set the Parameter properties of QryCat5_8_TotalValue from VB code.
The code I have come up with, from looking at other posts, is:
Dim RsMissingTimes As Recordset
CurrentDb.QueryDefs("QryCat5_8_TotalValue").Parameters("Hourly_Rate") = Eval(Forms!FrmFunctions!txtHourlyRate)
CurrentDb.QueryDefs("QryCat5_8_TotalValue").Parameters("Works_Overhead") = Eval(Forms!FrmFunctions!txtWorksOverhead)
Set RsMissingTimes = CurrentDb.OpenRecordset("QryMissingTimes")
However when i gets to the Set RsMissingTimes line it still gives me the "Too few parameters. Expected 2" Error.
When I debug and print the value of CurrentDb.QueryDefs("QryCat5_8_TotalValue").Parameters("Hourly_Rate") it gives me nothing when Forms!FrmFunctions!txtHourlyRate definately has a value in it.
Could anyone tell me what is going on and how I can get round this?
The code I have come up with, from looking at other posts, is:
Dim RsMissingTimes As Recordset
CurrentDb.QueryDefs("QryCat5_8_TotalValue").Parameters("Hourly_Rate") = Eval(Forms!FrmFunctions!txtHourlyRate)
CurrentDb.QueryDefs("QryCat5_8_TotalValue").Parameters("Works_Overhead") = Eval(Forms!FrmFunctions!txtWorksOverhead)
Set RsMissingTimes = CurrentDb.OpenRecordset("QryMissingTimes")
However when i gets to the Set RsMissingTimes line it still gives me the "Too few parameters. Expected 2" Error.
When I debug and print the value of CurrentDb.QueryDefs("QryCat5_8_TotalValue").Parameters("Hourly_Rate") it gives me nothing when Forms!FrmFunctions!txtHourlyRate definately has a value in it.
Could anyone tell me what is going on and how I can get round this?