I am trying to write code in VB6 to replace the following VBA code...
PartNo = DLookup("[PartNo]", "EnquiryDesk", "[JobNo]='" & Forms![QAReview]![JobNo] & "'")
This line looks at the field value of the JobNo field in the live/open form/table named "QAReview", finds the same field value for same JobNo field in the unopened/invisible form named "EnquiryDesk" and then returns the field value for the field PartNo for that JobNo from EnquiryDesk table.
I need this code to execute when a chkBox is ticked but understand from previous posts that I need to use a txtBox instead. I have listed the code I have started with but wonder if I am heading in he direction...
General...
Dim Conn As ADODB.Connection
Dim rsJobs As New ADODB.Recordset
Dim rsEnq As New ADODB.Recordset
Load QAReview Form...
Sub Form_Load()
Set Conn = New ADODB.Connection
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\000-QualityControlProgram\QC5.mdb;Persist Security Info=False"
Set rsJobs = New ADODB.Recordset
rsJobs.CursorType = adOpenForwardOnly
rsJobs.LockType = adLockReadOnly
rsJobs.CursorLocation = adUseClient
rsJobs.Open "Select * From QAContractReview", Conn
End Sub
'And here I am trying to open Enquiry Desk Table...
Set rsEnq = New ADODB.Recordset
rsEnq.CursorType = adOpenForwardOnly
rsEnq.LockType = adLockReadOnly
rsEnq.CursorLocation = adUseClient
rsEnq.Open "Select * From EnquiryDesk", Conn
EnqJobNo = txtFields(9)'<<< txtField(9) is JobNo field in EnquiryDesk table
MsgBox JobNo & EnqJobNo
'The program stops here with error...
"Control array element '9' does not exist"
So any help would be very much appreciated.
PartNo = DLookup("[PartNo]", "EnquiryDesk", "[JobNo]='" & Forms![QAReview]![JobNo] & "'")
This line looks at the field value of the JobNo field in the live/open form/table named "QAReview", finds the same field value for same JobNo field in the unopened/invisible form named "EnquiryDesk" and then returns the field value for the field PartNo for that JobNo from EnquiryDesk table.
I need this code to execute when a chkBox is ticked but understand from previous posts that I need to use a txtBox instead. I have listed the code I have started with but wonder if I am heading in he direction...
General...
Dim Conn As ADODB.Connection
Dim rsJobs As New ADODB.Recordset
Dim rsEnq As New ADODB.Recordset
Load QAReview Form...
Sub Form_Load()
Set Conn = New ADODB.Connection
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\000-QualityControlProgram\QC5.mdb;Persist Security Info=False"
Set rsJobs = New ADODB.Recordset
rsJobs.CursorType = adOpenForwardOnly
rsJobs.LockType = adLockReadOnly
rsJobs.CursorLocation = adUseClient
rsJobs.Open "Select * From QAContractReview", Conn
End Sub
'And here I am trying to open Enquiry Desk Table...
Set rsEnq = New ADODB.Recordset
rsEnq.CursorType = adOpenForwardOnly
rsEnq.LockType = adLockReadOnly
rsEnq.CursorLocation = adUseClient
rsEnq.Open "Select * From EnquiryDesk", Conn
EnqJobNo = txtFields(9)'<<< txtField(9) is JobNo field in EnquiryDesk table
MsgBox JobNo & EnqJobNo
'The program stops here with error...
"Control array element '9' does not exist"
So any help would be very much appreciated.