Thanks Graham, Now reports

G

Guest

Thanks Graham, apart from me changing some names for controls and objects. It
worked like magic. Below is the code again u gave me.
"A bit of the old Kiwi Ingenuity" :)

Now I have a query that incoporates planting information, application of
operations information and the products (spary chemicals) used.

I would like to use the same values supplied from txtApplicationDate,
cboOperations, lstPlantings and lstProducts as parameter values to send the
currently viewed selection to a report.
I may need a different / new command button to for this purpose.

On my report design, I have OperationID header to hold operations info and
PlantingDetailsID Header/Footer to hold selected planting details
and would like to display the selected products on the details section.

Here is the the code that Graham gave me which is working to append records
to my tblApplication and tblApplicationDetails.

Private Sub btnAppend_Click()
Dim db As DAO.Database
Dim rsApplication As DAO.Recordset
Dim rsApplicationDetails As DAO.Recordset
Dim vPlanting As Variant
Dim vProduct As Variant
Dim lApplicationID As Long
Set db = CurrentDb
Set rsApplication = db.OpenRecordset("tblApplications")
Set rsApplicationDetails = db.OpenRecordset("tblApplicationDetails")
For Each vPlanting In lstPlantings.ItemsSelected
With rsApplication
.AddNew
!ApplicationDate = txtApplicationDate
!OperationID = cboOperation
!PlantingDetailsID = lstPlantings.ItemData(vPlanting)
lApplicationID = !ApplicationID
.Update
End With
For Each vProduct In lstProducts.ItemsSelected
With rsApplicationDetails
.AddNew
!ApplicationID = lApplicationID
!ProductID = lstProducts.ItemData(vProduct)
.Update
End With
Next vProduct
Next vPlanting
rsApplication.Close
rsApplicationDetails.Close
End Sub
 
G

Guest

This post was supposed to be a reply to my thread below named "Multiselect
Listbox Question" which I accidentally posted as another question. Yes, it is
a question but wrong to have it as a new thread. Sorry my bad for any
inconveniences caused.

niuginikiwi
Nelson, New Zealand
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top