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.
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)
Regards
Chris
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"));
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)
Regards
Chris
ASKER
Which event should I put this code?
I think you have point here!
Regards
Chris
DoCmd.GoToControl "TheNameOfYour_Subform" ' Just replace it with the name of the subform.
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
I think you have point here!
Regards
Chris
Just put it in an event...probably a button
ASKER
I think it should be
DoCmd.GoToControl Me.sfrmGrnDetails Subform
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?
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?
ASKER
This code works...tested right now
Private Sub CboOrder_AfterUpdate()
Me.sfrmGrnDetails_Subform.SetFocus
DoCmd.RunCommand acCmdSelectAllRecords
DoCmd.RunCommand acCmdCopy
End Sub
There was an issue referring to the subform as control...but SetFocus resolved nicely.
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.
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.
ASKER
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
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
ASKER
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
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
ASKER
SelectAllRecords
True but the code given is failing, where do I go wrong?
Regards
Chris
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.
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.
ASKER
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
What do mean the form is properly linked to parent form without issues sir!
Regards
Chris
ASKER
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????????????????
That is too time consuming imagine you have 2000 line to start selecting manually????????????????
ASKER
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:
Regards
Chris
Private Sub purchaseID_GotFocus()
'When the combo box receives focus
'display in drop down position
Me.purchaseID.Dropdown
End Sub
Regards
Chris
you missed my comment...
ASKER
Do you mean that the subform isn't going to get populated ?
That you just want to capture the "filtered" combobox?
That you just want to capture the "filtered" combobox?
ASKER
you missed my comment..
Where is it?????????
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.
ASKER
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
That you just want to capture the "filtered" combobox?
Very very Correct!!!!
Regards
Chris
ASKER
Ok
Thank you sir you tried to help but All I wanted to capture only the filtered data nothing else at all
Regards
Chris
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...
If understood your workflow then you rapidly input items via barcode....then the subform oughts to get populated...
ASKER
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
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 .... :) )
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 .... :) )
ASKER
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
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" ?
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you so much Gustav
You have saved me again!
Regards
Chris
You have saved me again!
Regards
Chris
You are welcome!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sometimes you have to read between the lines!
The key was to study the screenshot the author so kindly attached the question.
Open in new window