Link to home
Create AccountLog in
Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc🇿🇲

How to use VBA in Ms Access to input multi combo box rows & columns
I’m now almost finishing my task and everything appear to work very well except one last bit which I thought was the easiest to do, here is a puzzle:

After creating a combo box in ms access with the below query and the VBA to populate the selected columns from the mentioned combo box all is well no issue see below:
Combo Box query
SELECT tblPurchasesDetailslines.PurchaseOrderID, tblPurchasesDetailslines.PurchaseID, tblProducts.ProductID, tblProducts.ProductName, tblPurchasesDetailslines.Quantity, tblPurchasesDetailslines.CostValue, tblPurchasesHeader.StatusStore
FROM (tblPurchasesDetailslines INNER JOIN tblProducts ON tblPurchasesDetailslines.ProductID = tblProducts.ProductID) INNER JOIN tblPurchasesHeader ON tblPurchasesDetailslines.PurchaseID = tblPurchasesHeader.PurchaseID
WHERE (((tblPurchasesDetailslines.PurchaseID)=[Forms]![frmGrn]![CboOrder]) AND ((tblPurchasesHeader.StatusStore) Is Null Or (tblPurchasesHeader.StatusStore)<>"2"));

Open in new window


VBA (used to input now the selected combo box columns)
Private Sub CboProducts_AfterUpdate()
Me.PurchasesID = Forms!frmGrn!txtGrnsCosting
Me.ProductID = Me.CboProducts.Column(2)
Me.Qty = Me.CboProducts.Column(4)
Me.Cost = Me.CboProducts.Column(5)
Me.GrnStockAccName = "Stock"
Me.GrnStockAcc = "114-10-1000"
Me.SuspenseName = "GRN Suspense"
Me.SuspenseAcc = "121-12-1000"
Me.BSIDSTOCK = "2"
Me.BSIDSuspense = "3"
DoCmd.GoToRecord , , acNewRec
Me.Refresh
End Sub

Open in new window

All what I want is to simply capture/input all the rows & columns as per filter combo box instead of just one line. Whatever rows is in the filtered combo box
For example if the filtered combo box is showing 5 rows then all the rows must captured at once using the VBA above



User generated image

Zero AI Policy

We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.


Avatar of NatchiketNatchiket🇬🇧

It seems like there is a conceptual problem around the use of combo boxes here.  With a combo box you can only select ONE value from the list.  If there are five values in the list then only one value may be selected.  The alternative is to use a multiselect list-box (not a great idea in continuous forms, or even possible in datasheets afaik). From the way you have structured your question it looks like you are trying to populate a child table based on certain criteria.  Perhaps consider using an INSERT or UPDATE querty to push the values into the table or a recordset  to iterate though the 'combo box query' rows and put the data in the target table?

SOLUTION
Avatar of John TsioumprisJohn Tsioumpris🇬🇷

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Create Account

Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScHankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc🇿🇲

ASKER

If you want to capture all the values of the combo just iterate it's columns collection

Sorry sir I'm lost what do mean by  just iterate it's columns collection, kindly give an example I'm sure you have clear answer to my problem.

Regards

Chris

I do agree with you all

Perhaps consider using an INSERT or UPDATE querty to push the values into the table or a recordset  to iterate though the 'combo box query' rows and put the data in the target table?

Can an update query used to populate a subform in ms access?

Reward 1Reward 2Reward 3Reward 4Reward 5Reward 6

EARN REWARDS FOR ASKING, ANSWERING, AND MORE.

Earn free swag for participating on the platform.


ASKER CERTIFIED SOLUTION
Avatar of NatchiketNatchiket🇬🇧

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

SOLUTION
Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.

SOLUTION
Avatar of ste5anste5an🇩🇪

Link to home
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Microsoft Access

Microsoft Access

--

Questions

--

Followers

Top Experts

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.