Link to home
Start Free TrialLog in
Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScFlag for Zambia

asked on

How to select all lines from a combobox not just One by One in Ms Access

I want to select all the items in a combobox in Ms Access as you can see the combo query below is already filtered so that only the specified record can be populated.


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


Instead of select line by line how can I select all the in combobox since the combobox details is already filtered, it very time consuming when capturing data line by line , for example imagine a purchase order may have 2000 lines now when creating a goods received note why not selecting all the lines in the GRN combo instead of line by line until all the 2000 lines finishes surely there must a way. (Selecting all mean all the data will populated as captured in the datasheet , example all the 2000 lines will show captured rather than selecting one by one)

User generated image
Regards

Chris
Avatar of John Tsioumpris
John Tsioumpris
Flag of Greece image

DoCmd.GoToControl "TheNameOfYour_Subform"  ' Just replace it with the name of the subform.
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy 

Open in new window

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

ASKER

Which event should I put this code?

DoCmd.GoToControl "TheNameOfYour_Subform"  ' Just replace it with the name of the subform.
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy 

Open in new window


I think you have point here!


Regards

Chris
Just put it in an event...probably a button
Here is the error message it say command NOT available for copying


User generated image

Private Sub CboOrder_AfterUpdate()
DoCmd.GoToControl "sfrmGrnDetails Subform"  ' Just replace it with the name of the subform.
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
End Sub

Open in new window

I think it should be
DoCmd.GoToControl Me.sfrmGrnDetails Subform 

Open in new window

Christopher,

I don't know what combo box you are talking about, I only see two on your form, but you cannot select multiple items from a combo box, only a listbox.

Can you circle the combo you are talking about in your screen shot?
Ok see the screen shoots

User generated image

Kindly check the parent form is showing 21 and the subform is also showing 21

Regards

Chris
This code works...tested right now
Private Sub CboOrder_AfterUpdate()

Me.sfrmGrnDetails_Subform.SetFocus
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
End Sub

Open in new window

There was an issue referring to the subform as control...but SetFocus resolved nicely.
Still there are errors see screen shoot


User generated image
You are missing something...i have just tested the code and it works as it should....put a breakpoint to see where and why it fails..
SelectAllRecords would select all the Records on a Form, not a combo.

It seems to me you want to populate your subform with all records with all the records available based on user selection. I'm not sure how your Form and Subform are setup, but when you select the Order Number in the Parent form, you should fill the Subform with all the Orders related to that Order Number. You could then use SelectAllRecords as John suggests.
The error point is coming from the time when I select the update combox  called CboOrder, this where people are expected to select the Purchase order in question so that it populate in the subform of the GrNlinedetails.

For example when you select the Purchase order number (PK) from the parent form then the details of the purchases order must populate in the GRN data sheet or subform.

Regards

Chri
Scot

It seems to me you want to populate your subform with all records with all the records available based on user selection. I'm not sure how your Form and Subform are setup, but when you select the Order Number in the Parent form

Very correct


Regards

Chris
SelectAllRecords

True but the code given is failing, where do I go wrong?

Regards

Chris
Have you copy/pasted my code ? exactly
Have you set the Master and Child linking fields to the correct values? If you do that, Access should take care of the rest for you, and you should then be able to use SelectAllRecords.
Exactly as see screen shoot



User generated image
Your code is failing because you don't have actually any data on the subform...as soon there are some data it would work nicely...just tested.
Have you set the Master and Child linking fields to the correct values? If you do that, Access should take care of the rest for you, and you should then be able to use SelectAllRecords.

What do mean the form is properly linked to parent form without issues sir!

Regards



Chris
No the data is hidden in the combo called PurchasesID , all I want is to have it visible NOT start selecting it again, the selection that is done from the parent combo should populate the subform , but what is happen the subform will only have the data hidden in the combobox Called purchaseID until it is selected manually.


That is too time consuming imagine you have 2000 line to start selecting manually????????????????
The code below will make the combobox dropdown open, but I want the content to be captured or INPUT in the data  not just to visible:

Private Sub purchaseID_GotFocus()
'When the combo box receives focus
'display in drop down position
    Me.purchaseID.Dropdown
End Sub

Open in new window


Regards

Chris
you missed my comment...
The code below display the exactly data that need to be inputed in the same cells . Please check where there is pepsi , shavel etc


Private Sub CboProducts_GotFocus()
'When the combo box receives focus
'display in drop down position
    Me.CboProducts.Dropdown
End Sub

Open in new window


Are we saying there is no way ?

User generated image
Do you mean that the subform isn't going to get populated ?
That you just want to capture the "filtered" combobox?
you missed my comment..

Where is it?????????
Your code is failing because you don't have actually any data on the subform...as soon there are some data it would work nicely...just tested.
Do you mean that the subform isn't going to get populated ?
That you just want to capture the "filtered" combobox?

Very very Correct!!!!


Regards

Chris
Ok

Thank you sir you tried to help but All I wanted to capture only the filtered data nothing else at all

Regards

Chris
This is a totally different case.....are you sure that you are working to work like this...?
If understood your workflow then you rapidly input items via barcode....then the subform oughts to get populated...
No Sir

This is just a goods received note using the data from the purchase order we do not want to recapture the same data manually that is why when we filtered the targeted purchase order its content must populate in the the GRN subform automatically inputed.

Regards

Chris
If its the combobox then what exactly and why you are trying to copy ?
I will guess that you have e.g. 10 sales items on order 21....this should be written to the source of the combobox...so just make a query and use this to populate the subform...i am pretty sure i have some code in one of your older questions ...(i am also pretty sure you picked something else as the solution .... :)       )
Kindly note these sales transaction but purchases

Before we buy we send a purchase order to the supplier of goods

When we receive the goods we create the goods received note which will have the exactly details as per purchases order.

That is why we DO NOT need to start recapturing again the GRN
So you already have the data in purchase order (?)
Just perform a simple INSERT to the Source of the Subform....to populate it...
you want to keep minimum data...just add a table/field that the data from the purchase order are also belonging to the goods received note.
And when you say "copy" where are you going to "paste" ?
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you so much Gustav

You have saved me again!

Regards

Chris
You are welcome!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sometimes you have to read between the lines!
The key was to study the screenshot the author so kindly attached the question.