I have been wrestling with the following VBA code for the last two days. I am endeavoring to take a table of payment factors (2 records) and extract from it the correct record that matches the parameter passed from the control table, which has 1145 records. The purpose is to create a new table with 1145 records that pass the key field from the control table and the correct fields from the Payment Factors table.
When I run the SUB, the query I have created to get the data from the factors tables based on the parameter, StartDate >= vDisDate and EndDate<= vDisDate gives me a "Run Time Error 3061. Two Few Parameters. Expected 1.
Option Compare Database
Public Sub Rates()
Dim vWI As Variant
Dim vSTDRT As Variant
Dim vLBRSHR As Variant
Dim vFEDNL As Variant
Dim vIMEDSH As Variant
Dim vCAPFEDRT As Variant
Dim vLRGURBAN As Variant
Dim vCAPIMEDSH As Variant
Dim vGAF As Variant
Dim vOPERCCR As Variant
Dim vCAPCCR As Variant
Dim vLBRREL As Variant
Dim vNONREL As Variant
Dim vFIXLOSS As Variant
Dim vRATIO As Variant
Dim vSDATE As Date
Dim vEDATE As Date
Dim vVisitID As String
Dim vDisDate As Date
Dim X As Integer
Dim Z As Integer
Dim RecCount As Integer
Dim RST As DAO.Recordset
Dim RST1 As DAO.Recordset
Dim RST2 As DAO.Recordset
Set RST = CurrentDb.OpenRecordset("TblDischargeList", dbOpenDynaset)
Set RST2 = CurrentDb.OpenRecordset("TblMedicareFactors_VisitID", dbOpenDynaset)
With RST
Do While Not RST.EOF
TempVars.Add "vVisitID", RST![VisitID].Value
TempVars.Add "vDisDate", RST![DischargeDateTime].Value
Set RST1 = CurrentDb.OpenRecordset("qrySubRates", dbOpenDynaset)
With RST1
vWI.Value = !WI
vSTDRT.Value = !StdRate
vFEDNL.Value = !FedNonLbr
vIMEDSH.Value = !IME_DSH
vCAPFEDRT.Value = !CAPFEDRT
vLRGURBAN.Value = !LargeUrban
vCAPIMEDSH.Value = !CapIME_DSH
vGAF.Value = !GAF
vOPERCCR.Value = !OperCCR
vCAPCCR.Value = !CapOLCCR
vLBRREL.Value = !LBRRel
vNONREL.Value = !NonLBRRel
vFIXLOSS.Value = !FixedLoss
vRATIO.Value = !Ratio
vSDATE = !StartDate.Value
vEDATE = !EndDate.Value
End With
With RST2
.AddNew
![VisitID].Value = [TempVars]![vVisitID]
![WageIndex].Value = vWI
![StdRate].Value = vSTDRT
![FedNonLbr].Value = vFEDNL
![IME_DSH].Value = vIMEDSH
![CAPFEDRT].Value = vCAPFEDRT
![LargeUrban].Value = vLRGURBAN
![CapIME_DSH].Value = vCAPIMEDSH
![GAF].Value = vGAF
![OperCCR].Value = vOPERCCR
![CapOLCCR].Value = vCAPCCR
![LBRRel].Value = vLBRREL
![NonLBRRel].Value = vNONREL
![FixedLoss].Value = vFIXLOSS
![Ratio].Value = vRATIO
![StartDate].Value = vSDATE
![EndDate].Value = vEDATE
.Update
End With
RST.MoveNext
Loop
End With
End Sub
Any help with this will be greatly appreciated.
GPSPOW
When I run the SUB, the query I have created to get the data from the factors tables based on the parameter, StartDate >= vDisDate and EndDate<= vDisDate gives me a "Run Time Error 3061. Two Few Parameters. Expected 1.
Option Compare Database
Public Sub Rates()
Dim vWI As Variant
Dim vSTDRT As Variant
Dim vLBRSHR As Variant
Dim vFEDNL As Variant
Dim vIMEDSH As Variant
Dim vCAPFEDRT As Variant
Dim vLRGURBAN As Variant
Dim vCAPIMEDSH As Variant
Dim vGAF As Variant
Dim vOPERCCR As Variant
Dim vCAPCCR As Variant
Dim vLBRREL As Variant
Dim vNONREL As Variant
Dim vFIXLOSS As Variant
Dim vRATIO As Variant
Dim vSDATE As Date
Dim vEDATE As Date
Dim vVisitID As String
Dim vDisDate As Date
Dim X As Integer
Dim Z As Integer
Dim RecCount As Integer
Dim RST As DAO.Recordset
Dim RST1 As DAO.Recordset
Dim RST2 As DAO.Recordset
Set RST = CurrentDb.OpenRecordset("TblDischargeList", dbOpenDynaset)
Set RST2 = CurrentDb.OpenRecordset("TblMedicareFactors_VisitID", dbOpenDynaset)
With RST
Do While Not RST.EOF
TempVars.Add "vVisitID", RST![VisitID].Value
TempVars.Add "vDisDate", RST![DischargeDateTime].Value
Set RST1 = CurrentDb.OpenRecordset("qrySubRates", dbOpenDynaset)
With RST1
vWI.Value = !WI
vSTDRT.Value = !StdRate
vFEDNL.Value = !FedNonLbr
vIMEDSH.Value = !IME_DSH
vCAPFEDRT.Value = !CAPFEDRT
vLRGURBAN.Value = !LargeUrban
vCAPIMEDSH.Value = !CapIME_DSH
vGAF.Value = !GAF
vOPERCCR.Value = !OperCCR
vCAPCCR.Value = !CapOLCCR
vLBRREL.Value = !LBRRel
vNONREL.Value = !NonLBRRel
vFIXLOSS.Value = !FixedLoss
vRATIO.Value = !Ratio
vSDATE = !StartDate.Value
vEDATE = !EndDate.Value
End With
With RST2
.AddNew
![VisitID].Value = [TempVars]![vVisitID]
![WageIndex].Value = vWI
![StdRate].Value = vSTDRT
![FedNonLbr].Value = vFEDNL
![IME_DSH].Value = vIMEDSH
![CAPFEDRT].Value = vCAPFEDRT
![LargeUrban].Value = vLRGURBAN
![CapIME_DSH].Value = vCAPIMEDSH
![GAF].Value = vGAF
![OperCCR].Value = vOPERCCR
![CapOLCCR].Value = vCAPCCR
![LBRRel].Value = vLBRREL
![NonLBRRel].Value = vNONREL
![FixedLoss].Value = vFIXLOSS
![Ratio].Value = vRATIO
![StartDate].Value = vSDATE
![EndDate].Value = vEDATE
.Update
End With
RST.MoveNext
Loop
End With
End Sub
Any help with this will be greatly appreciated.
GPSPOW