D
Deano
I have already posted this a couple of days ago and have come stuck with the
help I received. What I am trying to do is create a new record in a header
table and details in a detail table. To do this I am have 2 list boxes.
One (Header) with a list of suppliers and the 2nd(Footer) is a list of parts
that are related to the supplier selected. I then want to be able to click
a button which will create an order with the data in the listboxes. here's
my code below.
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim lngIDNumber As Long
Set db = CurrentDb
Set rs = db.OpenRecordset("MasterTable")
Set rs1 = db.OpenRecordset("DetailsTable")
rs.AddNew
rs![SupplierID] = lstSuppliers.Column(0)
rs![Description] = "Testing Order Enquiry Entries"
rs![Status] = "Created"
rs![Notes] = "This is great"
lngIDNumber = rs![OrderEnquiryID]
rs.Update
For k = 0 To Me.lstPartsReq.ListCount
Debug.Assert Me.lstPartsReq.ItemData(k)
rs1.AddNew
rs1![OEID] = lngIDNumber
rs1![PartID] = lstPartsReq.Column(0)
rs1![Description] = lstPartsReq.Column(1)
rs1![Quantity] = lstPartsReq.Column(2)
rs1.Update
Next
rs.Close
rs1.Close
The problem is that no data appears in the fields within the detail records.
I have also learned that the Me.lstPartsReq.ListCount will include the
headers on the listbox and it only include 1 field of the listbox which is
ithe PartID. I need to populate a few more fields.
I know this post is a little long but I am stuck. If anyone can help or
suggest another way it would be much appreciated.
Thanks
help I received. What I am trying to do is create a new record in a header
table and details in a detail table. To do this I am have 2 list boxes.
One (Header) with a list of suppliers and the 2nd(Footer) is a list of parts
that are related to the supplier selected. I then want to be able to click
a button which will create an order with the data in the listboxes. here's
my code below.
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim rs1 As DAO.Recordset
Dim lngIDNumber As Long
Set db = CurrentDb
Set rs = db.OpenRecordset("MasterTable")
Set rs1 = db.OpenRecordset("DetailsTable")
rs.AddNew
rs![SupplierID] = lstSuppliers.Column(0)
rs![Description] = "Testing Order Enquiry Entries"
rs![Status] = "Created"
rs![Notes] = "This is great"
lngIDNumber = rs![OrderEnquiryID]
rs.Update
For k = 0 To Me.lstPartsReq.ListCount
Debug.Assert Me.lstPartsReq.ItemData(k)
rs1.AddNew
rs1![OEID] = lngIDNumber
rs1![PartID] = lstPartsReq.Column(0)
rs1![Description] = lstPartsReq.Column(1)
rs1![Quantity] = lstPartsReq.Column(2)
rs1.Update
Next
rs.Close
rs1.Close
The problem is that no data appears in the fields within the detail records.
I have also learned that the Me.lstPartsReq.ListCount will include the
headers on the listbox and it only include 1 field of the listbox which is
ithe PartID. I need to populate a few more fields.
I know this post is a little long but I am stuck. If anyone can help or
suggest another way it would be much appreciated.
Thanks