In the code below, I want the information that is entered from the input box to be written to two different tables. More accurately, I want all of the information to be written to a "check out" table for record purposes. Moreover, I want the information relating to Parts such as part number and quantity to relate to interact with the parts table. I have facilitated the latter with the code below. However, my attempt to write and save to the "Check Out" table has failed.
The code is below.
Public Function CheckOut()
'declare variables and assign address to object variables
Dim strClkNo As String, strPartNo As String, IntQuantity As Integer
Dim PartNo As ADODB.Connection, rstPartNo As ADODB.Recordset
Set PartNo = Application.CurrentProject.Connection
Set rstPartNo = New ADODB.Recordset
Dim Conn1 As ADODB.Connection, rstChckOt As ADODB.Recordset
Set Conn1 = Application.CurrentProject.Connection
Set rstChckOt = New ADODB.Recordset
'Open the Chckot recordset
rstChckOt.Open Source:="CheckOut", ActiveConnection:=Conn1, _
CursorType:=adOpenForwardOnly, LockType:=adLockPessimistic
'open the PartsNo recordset
rstPartN
pen Source:="Parts", ActiveConnection:=PartNo, _
CursorType:=adOpenForwardOnly, LockType:=adLockPessimistic
'Enter Clock Number, Part Number and Quantity of that same part
strClkNo = InputBox(prompt:="Please enter or scan your clock number:", Title:="Scan or Enter your Clock Number"
strPartNo = InputBox(prompt:="Please enter or scan the part number of your part:", Title:="Scan or Enter Part Number"
IntQuantity = InputBox(prompt:="Using the keyboard, please enter the quantity of that part you are checking out:", Title:="Quantity of previous part number you are checking out"
'Work this section out and your program will work.
strClkNo = rstChckOt.Fields("ClockNumber"
strPartNo = rstChckOt.Fields("PartNumber"
IntQuantity = rstChckOt.Fields("Quantity"
'Save ChckOt1 recordset
rstChckOt.Update
'Close Chckot1 recordset
rstChckOt.Close
'Diassociate object variable from object
Set rstChckOt = Nothing
'Search for and subtract from Parts record in "Parts" table using rstPartNo
rstPartNo.Find criteria:="PartNumber = '" & strPartNo & "'"
rstPartNo.Fields("UnitsInStock"
.Value = rstPartNo.Fields("UnitsInStock"
.Value - IntQuantity
'Save changes to PartNo recordset
rstPartNo.Update
'Close PartNo recordset
rstPartNo.Close
'Diassociate object variable from object
Set rstPartNo = Nothing
End Function
Thanks for any help in advance.
Inquisitor
The code is below.
Public Function CheckOut()
'declare variables and assign address to object variables
Dim strClkNo As String, strPartNo As String, IntQuantity As Integer
Dim PartNo As ADODB.Connection, rstPartNo As ADODB.Recordset
Set PartNo = Application.CurrentProject.Connection
Set rstPartNo = New ADODB.Recordset
Dim Conn1 As ADODB.Connection, rstChckOt As ADODB.Recordset
Set Conn1 = Application.CurrentProject.Connection
Set rstChckOt = New ADODB.Recordset
'Open the Chckot recordset
rstChckOt.Open Source:="CheckOut", ActiveConnection:=Conn1, _
CursorType:=adOpenForwardOnly, LockType:=adLockPessimistic
'open the PartsNo recordset
rstPartN
CursorType:=adOpenForwardOnly, LockType:=adLockPessimistic
'Enter Clock Number, Part Number and Quantity of that same part
strClkNo = InputBox(prompt:="Please enter or scan your clock number:", Title:="Scan or Enter your Clock Number"
strPartNo = InputBox(prompt:="Please enter or scan the part number of your part:", Title:="Scan or Enter Part Number"
IntQuantity = InputBox(prompt:="Using the keyboard, please enter the quantity of that part you are checking out:", Title:="Quantity of previous part number you are checking out"
'Work this section out and your program will work.
strClkNo = rstChckOt.Fields("ClockNumber"
strPartNo = rstChckOt.Fields("PartNumber"
IntQuantity = rstChckOt.Fields("Quantity"
'Save ChckOt1 recordset
rstChckOt.Update
'Close Chckot1 recordset
rstChckOt.Close
'Diassociate object variable from object
Set rstChckOt = Nothing
'Search for and subtract from Parts record in "Parts" table using rstPartNo
rstPartNo.Find criteria:="PartNumber = '" & strPartNo & "'"
rstPartNo.Fields("UnitsInStock"
'Save changes to PartNo recordset
rstPartNo.Update
'Close PartNo recordset
rstPartNo.Close
'Diassociate object variable from object
Set rstPartNo = Nothing
End Function
Thanks for any help in advance.
Inquisitor