B
Bill
Greetings.
I have to populate a table from a table in another
database.
Reason is too produce packing slips and commercial
invoices, and the packing slip etc can vary from the
quote, so a starting point list is required.
I am using a combo box on the form to select the Quote
(Number). Everthing returned by the filter must be copied
to the new table (subform)- There can be more than one
line as the original table was a parent child.
I am playing with the following but not getting any
success.
Any ideas?.
Sub SubformControls()
'Using the selected number from the combo box
Dim strFilter As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim str As String
'Locate and open the reference table for the recordset
'and isolate the required records based on the filter
'Filter is set from the combobox on the form.
Set rs = CurrentDb.OpenRecordset("select*From[tblInventory
Tracking]where [Works No:]=" & [WorksNumber].Column(0))
rs.MoveFirst
Do Until rs.EOF
'Update the SubForm Controls from the dlookup in the
recordset
strFilter = "[Works No:]= " & [WorksNumber].Column(0)
Me![SubForm subform]![Quantity] = Nz(DLookup
("[Qty:]", "[tblInventory Tracking]", strFilter))
Me![SubForm subform]![Description] = Nz(DLookup("[Invoice
Details:]", "[tblInventory Tracking]", strFilter))
Me![SubForm subform]![UnitPrice] = Nz(DLookup("[Price
$]", "[tblInventory Tracking]", strFilter))
Me![SubForm subform]![Total] = Nz(DLookup("[Total
Price:]", "[tblInventory Tracking]", strFilter))
rs.MoveNext
Loop
rs.Close
End Sub
What ever I do i get one line one record, but there can
be other results. Any help appreciated.
Kind Regards
Bill
I have to populate a table from a table in another
database.
Reason is too produce packing slips and commercial
invoices, and the packing slip etc can vary from the
quote, so a starting point list is required.
I am using a combo box on the form to select the Quote
(Number). Everthing returned by the filter must be copied
to the new table (subform)- There can be more than one
line as the original table was a parent child.
I am playing with the following but not getting any
success.
Any ideas?.
Sub SubformControls()
'Using the selected number from the combo box
Dim strFilter As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim str As String
'Locate and open the reference table for the recordset
'and isolate the required records based on the filter
'Filter is set from the combobox on the form.
Set rs = CurrentDb.OpenRecordset("select*From[tblInventory
Tracking]where [Works No:]=" & [WorksNumber].Column(0))
rs.MoveFirst
Do Until rs.EOF
'Update the SubForm Controls from the dlookup in the
recordset
strFilter = "[Works No:]= " & [WorksNumber].Column(0)
Me![SubForm subform]![Quantity] = Nz(DLookup
("[Qty:]", "[tblInventory Tracking]", strFilter))
Me![SubForm subform]![Description] = Nz(DLookup("[Invoice
Details:]", "[tblInventory Tracking]", strFilter))
Me![SubForm subform]![UnitPrice] = Nz(DLookup("[Price
$]", "[tblInventory Tracking]", strFilter))
Me![SubForm subform]![Total] = Nz(DLookup("[Total
Price:]", "[tblInventory Tracking]", strFilter))
rs.MoveNext
Loop
rs.Close
End Sub
What ever I do i get one line one record, but there can
be other results. Any help appreciated.
Kind Regards
Bill