Hello,
I have a Table "JobTypesT" and another Table "JobInfoT"
JobInfoT holds all the information of the Job.
JobTypesT holds a certain amount of days depending on the job type and then the process type.
I am trying to achieve, look at one date then get the days from JobTypesT where they match and retrieve the number.
Getting some errors in the following code. (Item cannot be found in the collection corresponding to the request.....)
At the rs.Open sql, con, 1
In this instance should say 18
I believe (I think) the error is coming from this code
Is it because my fields are named the same?
Thank you
I have a Table "JobTypesT" and another Table "JobInfoT"
JobInfoT holds all the information of the Job.
JobTypesT holds a certain amount of days depending on the job type and then the process type.
I am trying to achieve, look at one date then get the days from JobTypesT where they match and retrieve the number.
Getting some errors in the following code. (Item cannot be found in the collection corresponding to the request.....)
At the rs.Open sql, con, 1
In this instance should say 18
Code:
Function GetDays(sVal)
Dim db As Database
Dim sql As String, sVal1 As String, sVal2 As String
Dim con As Object
Dim rs As Object
Set con = Application.CurrentProject.Connection
Set db = CurrentDb
sql = "SELECT " & sVal & " FROM JobTypesT WHERE JobTypesID = " & Me.CboJobTypeID
Set rs = CreateObject("ADODB.Recordset")
rs.Open sql, con, 1
dValue = rs(0)
rs.Close
Set rs = Nothing
GetDays = dValue
End Function
I believe (I think) the error is coming from this code
Code:
'------------------------------------------------------------
Private Sub BtnUpdate_Click()
Dim db As Database
Dim sql As String, sVal1 As String, sVal2 As String
Dim con As Object
Dim rs As Object
Dim dDate As Date
Dim iLoop As Integer, iDays As Integer ', iAcct As Integer
Set con = Application.CurrentProject.Connection
Set db = CurrentDb
' CboCustomerID.SetFocus
' If CboCustomerID.Text = "" Then
' MsgBox "Please select a customer from the list", vbInformation, "Select Customer"
' Exit Sub
' End If
CboJobTypeID.SetFocus
If CboJobTypeID.Text = "" And Nz(Me.Lead_Date, "") = "" Then
Exit Sub
End If
If CboJobTypeID.Text = "" Then
MsgBox "Please select a Job Type from the list", vbInformation, "Select Job Type"
Exit Sub
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
If Lead_Date.Value & "" = "" Then
Lead_Date.Value = Now()
End If
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Refresh
' sql = "SELECT systemdays FROM customer INNER JOIN PaymentT ON PaymentT.PaymentID = CustomerT.PaymentID WHERE CustomerID = " & Me.CboCustomerID
' Set rs = CreateObject("ADODB.Recordset")
' rs.Open sql, con, 1
'
' If rs.EOF Or rs.BOF Then
' iDays = 4
' Else
' iDays = rs(0)
' rs.Close
' Set rs = Nothing
' End If
sql = "UPDATE JobTypesT SET IFA_Due = #" & AddDays(GetDays("IFA_Due")) & "#,SampleSubm_Due = #" & AddDays(GetDays("SampleSubm_Due")) & _
"#,IFC_Due = #" & AddDays(GetDays("IFC_Due")) & "#,SetOutDue = #" & AddDays(GetDays("SetOutDue")) & _
"#,CarcassCut_Due = #" & AddDays(GetDays("CarcassCut_Due")) & "#,CarcassEdge_Due = #" & AddDays(GetDays("CarcassEdge_Due")) & _
"#,PFBCut_Due = #" & AddDays(GetDays("PFBCut_Due")) & "#,PFBEdge_Due = #" & AddDays(GetDays("PFBEdge_Due")) & _
"#,WhiteSatinCut_Due = #" & AddDays(GetDays("WhiteSatinCut_Due")) & "#,TwoPakPartsOut_Due = #" & AddDays(GetDays("TwoPakPartsOut_Due")) & _
"#,PickHW_Due = #" & AddDays(GetDays("PickHW_Due")) & "#,HingeDrill_Due = #" & AddDays(GetDays("HingeDrill_Due")) & _
"#,MachineShop_Due = #" & AddDays(GetDays("MachineShop_Due")) & "#,DrawerAss_Due = #" & AddDays(GetDays("DrawerAss_Due")) & _
"#,AssemblyDue = #" & AddDays(GetDays("AssemblyDue")) & "#,TwoPakUnderC_Due = #" & AddDays(GetDays("TwoPakUnderC_Due")) & _
"#,TwoPakPaint_Due = #" & AddDays(GetDays("TwoPakPaint_Due")) & "#,WrapQC_Due = #" & AddDays(GetDays("WrapQC_Due")) & _
"#,Delivery_Due = #" & AddDays(GetDays("Delivery_Due")) & "# WHERE JobID = " & Me.JobID
sql = "UPDATE JobInfoT SET Lead_Date = #" & AddOrderDays(GetDays("Lead_Date")) & _
"#,SET IFA_Due = #" & AddOrderDays(GetDays("SET IFA_Due")) & "#,SampleSubm_Due = #" & AddOrderDays(GetDays("SampleSubm_Due")) & _
"#,IFC_Due = #" & AddOrderDays(GetDays("IFC_Due")) & "#,SetOutDue = #" & AddOrderDays(GetDays("SetOutDue")) & _
"#,CarcassCut_Due = #" & AddOrderDays(GetDays("CarcassCut_Due")) & "#,CarcassEdge_Due = #" & AddOrderDays(GetDays("CarcassEdge_Due")) & _
"#,PFBCut_Due = #" & AddOrderDays(GetDays("PFBCut_Due")) & "#,PFBEdge_Due = #" & AddOrderDays(GetDays("PFBEdge_Due")) & _
"#,WhiteSatinCut_Due = #" & AddOrderDays(GetDays("WhiteSatinCut_Due")) & "#,TwoPakPartsOut_Due = #" & AddOrderDays(GetDays("TwoPakPartsOut_Due")) & _
"#,PickHW_Due = #" & AddOrderDays(GetDays("PickHW_Due")) & "#,HingeDrill_Due = #" & AddOrderDays(GetDays("HingeDrill_Due")) & _
"#,MachineShop_Due = #" & AddOrderDays(GetDays("MachineShop_Due")) & "#,DrawerAss_Due = #" & AddOrderDays(GetDays("DrawerAss_Due")) & _
"#,AssemblyDue = #" & AddOrderDays(GetDays("AssemblyDue")) & "#,TwoPakUnderC_Due = #" & AddOrderDays(GetDays("TwoPakUnderC_Due")) & _
"#,TwoPakPaint_Due = #" & AddOrderDays(GetDays("TwoPakPaint_Due")) & "#,WrapQC_Due = #" & AddOrderDays(GetDays("WrapQC_Due")) & _
"#,Delivery_Due = #" & AddOrderDays(GetDays("Delivery_Due")) & "# WHERE JobID = " & Me.JobID
db.Execute sql
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.Refresh
End Sub
Is it because my fields are named the same?
Thank you