Find Highlighted Row in Tab from Query - vba

I have a company form that list their basic info with a subform tab that list more company info like contacts, parts and orders. I use a tab control where each tab has a table with basic info about each that is populated from a query. I am trying to open another form that has detailed information about the user highlighted row in the query, but cannot figure out how to read which row is selected.
The form is called Customer, the tab form is called tabDetails, the parts tab is caled tabParts and the query that lists all the parts for the company is called qryPartsList.
This is what I thought would work.
ID = Me!tabDetails!tabParts!qryPartsList!CurrentRecord![ID]

The table is normally held in a subform control of the main form, and the ID will be that of the current record, so try:
ID = Me!qryPartsList.Form![ID].Value

My problem was I kept trying to call the query and not the object for the query. The tab's child object is what I needed to call. I named it 'Part_Info' and then Gustav's answer worked for me.
ID = Me!Part_Info.Form![ID].Value
Thanks!

Related

Multiple items form referring to a specific field

I have a multiple item form which takes records from a table:
this edit button I added in Design view , I want to be able to refer to the record which the button is bound to , like really simple task as msgbox this record ID

How to display out of list items in a combobox?

I have a tbl_ProjectList that includes the project's Name and End Date.
A qry_cboProject queries this table to only display projects in a combobox on Subform A where the End Date is after the selected date on Subform B, both on Mainform C.
On Subform A, a macro copies (INSERT INTO SQL) projects from Subform B's previous months into the new months. However, if an out-of-date project gets copied over to a new month, the combobox field would be empty for that record, even though the Key exists on the back-end.
I've tried playing with the combobox's properties on Subform A by changing the Bound Column, Column Count, Column Widths, and Limit To List, but am only able to get the out-of-date project to display by its Key, rather than its Name.
The front-end reasoning for this macro is that employees do not have to repetitively select the same projects for each month, and employees already working on out-of-date projects may still need to put in some hours to close out the project.
Does anyone have any suggestions? Thank you in advance!
The order in which fields show up in you combo box depends on how the control source is querying the information i.e. to get name and not the key to show up in a combobox using the a control source query like the following:
SELECT Key, Name FROM tbl_ProjectList
You would need to set the following attributes:
Column Count: 2
Column Width: 0"; 2"
Bound Column: 1
It sounds like you may need to requery the control source as well. This should cause all the information to update.
#Parfait - apologies for not describing my problem in more detail. There are multiple subforms on one main form to allow the user to select a date in one subform, which populates projects on a second subform and responsibilities on a third subform.
Jeffrey's suggestion made me realize that the underlying query to the combobox should be adjusted for projects that are carried over into new months, where a foreign key exists in the underlying tbl_ProjectUserEntry
Therefore, I added a WHERE criteria to the query, which uses a DLookUp function to see if the foreign key exists:
DLookUp("[DateID]","tbl_ProjectUserEntry","[DateID] =" & Forms.frm_UserEntry.tbDateID) IS NOT NULL
frm_UserEntry is the main form..
Again, apologies for my brief description to a complex problem.

Ideas for diplaying query results next to buttons

I have a temporary table that is created from a series of query with a VBA code. The name and number of fields in the table changes with the results of the queries.
Right now I simply open the table with DoCmd.OpenTable.
What I would like to do is display the table in a form so I can include some buttons for example to allow the user to export the table.
I tried a listbox but the formatting was not good and I can't add horizontal scroll bar to see all fields.
I tried a subform populated from the table, but it would not adapt to the changes of the table (fields and numbers).
Any Idea of what can I do next ?
the subform seems to be a good idea. When your table is ready to be shown, you can assign it to a subform object via Me.subFormName.SourceObject = "Table.tableName"
(of cource "subFormName" and "tableName" have to be replaced by the actual names of the subform and the table)

Creating a search query in Microsoft Access to query unbound fields and subform

I cannot seem to figure this out. I have made it very far with this database but now i am at a loss. I am going to post screenshots and details below and I hope it will be enough info.
This is my main form (dashboard). It shows the status of calls my employee has received. I need to implement a search. I would like it to search by customer or part.
My Goal is to have someone enter a string in the search field and retrieve matches to display on my details from (that contains a subfrom)
This is the detail screen. It shows the customer and the part(s) on the subform. All the customer info is unbound due to the way it is handled. I have a customer master table my employee can search from and add to the call. If the customer is not in my master table he can enter one manually. The unbound boxes are tied by a CustomerID field.
These are my Relationships for the database
This is the function that matches the CustomerID to fill the unbound boxes
This is my table for the detail form
And finally my table for the subform

Access multi selection list box as a criteria to INSERT, UPDATE OR DELETE records from a table

For a database with this schema (a product may belong to one or more categories):
Item_category(product, category_name)
Category(category_name)
Will it be possible for me to build a multi-selection list box (List box data source from the Category relation) using an Access form and then highlighting the categories that the product belongs to (by querying the Item_category table), and at the same time letting users select new categories or deselect highlighted categories so that when an "Update" button is pressed, VBA code will automatically determine either INSERT, UPDATE or DELETE queries are needed to update the Item_category table?
How can I do that? Thanks!
I've generally done this type of interface using a form which looks very much like the "Which fields do you want on your form?" in the Form Wizard. Where you have the Table/Query list of Available Fields in the table in the listbox on the left hand side and the Selected Fields in the listbox on the right hand side. Along with the move left and right command buttons in the middle. The users quite like this interface.
Added: Note that the left hand listbox contains all the category records which aren't present in the products category table. So a category would be present in one or the other listbox but never both.
You very likely will want to use the Multi Select property of the listbox. If you hit the help on that field in the property sheet it should lead you to a page which mentions the ItemsSelected collection. Visit that page for sample code on how to read all the items selected by the user. Or visit http://msdn.microsoft.com/en-us/library/aa196172%28v=office.11%29.aspx.