MSAccess Query Not Refreshing After Update - ms-access

I have simple table subform with 2 pulldown comboboxes. The challenge I'm having is that even though I've carefully mapped parameters to the subform's query driven table will NOT populate with data. I have made sure to have the "me.requery" event (after update) for each combobox pulldown.
Combobox 1 = [cmb_opt_verified]
Combobox 2 = [cmb_srv_capture_status]
The comboboxes are within a subform, that is embedded in to tab control, that is embedded into the parent Form
Where
Is the parent form
Is the subform
Is combobox 1
Is combobox 2
Is a table that is powered by a query with the combobox parameters mapped to it.
The table query has the subforms combo-box parameters mapped with respect to the subform's table. The expected result is a list from the application of combobox 1 AND combobox 2 user selection.
[Forms]![Server Data Workbench]![srv_AML_detail].[Form]![cmb_opt_verified]
[Forms]![Server Data Workbench]![srv_AML_detail].[Form]![cmb_srv_capture_status]
I've tried leaving the form running and switching between pulldown options, but not luck. The query is not updating at all even with refreshes. I am able to see the list if I hard code into the query either options from combobox 1 and combobox 2
Is there a way I can determine if the values that are in the comboboxes are truly making it to the query? Or is there something I'm missing in the mapping of the comboboxes to the form and query?
Any help is greatly appreciated.

Embarrassing.. my combobox was bounded to the wrong column. I fixed it by writing in a msgbox [forms]![blah]... and it displayed the recordID and not the text itself. Problem resolved. It's strange how in some cases the bounded column is right while in other cases it's wrong. guess it's MSAccess way to keep you on your toes - or the product is very buggy.

Related

Adding Records from a pop-up query to a subform within the main form using VBA, Access 2010

I have a main Purchase_Orders Form with an Items subform. I have also created a button that opens a popup form and queries previous Purchase orders for items that have been purchased from the same supplier which has been selected on the main form. I have added an unbound checkbox to this popup query.
Now what I want to be able to do, is have an "assign" button that will select each record in the query where the checkbox = true (or 1 I'm not sure). And then input those records in to the main subform, Items.
Is this possible? and any ideas how I may go about coding this in VBA? I am pretty new to VBA but if I get anywhere with the code, I will edit this post with further info. Thanks!
If you want to add multiple items at once then you will need to use some form of unbound control, and a VBA loop to insert.
The simplest way would be to load a multi-select enabled ListBox and use that to allow the user to choose items. Then upon clicking the Assign button, you can loop through the listbox and insert the items into the table.
If you want more specific help you're going to need to provide much more specific data. Table structures, form fields/data sources, form names, perhaps some VBA behind the forms.

Parameters in rowsource query

I have a combobox query that uses parameters from a parent item. When I first load the form the combobox is empty, if I go to design view and return to form view the combobox is populated with the correct items.
While searching for the cause of this I decided to create an extra text field that retrieves the same data from the same parent item. On the first launch that textbox is populated while the combobox remains empty.
My last step was to change the combobox query parameter to refer to the newly created textbox. After that the previously working textbox started out empty as well and became populated after going to design view and back.
My hypothesis - the query tries to retrieve the parameters before the text fields are filled. Keep in mind I have reversed loading order of main-form and sub-form as explained here.
I don't know what to google for any more
You can requery the combo in the current event of the main form like so:
Me.Subform1.Form.MyCombo.Requery

Access continuous forms and comboboxes

I have a continuous form with three comboboxes on it. Each one's recordsource is filtered based on the value in the preceding combobox. I am having a problem with the 2nd and subsequent records not referencing the values in their current record... they appear to be referencing the first records value. I have attached a picture to better illustrate the issue. My question is, how can I get the comboboxes on the 2nd and subsequent records to reference the value in their current record?
Thanks in advance guys!
Looks like there are some limitations in Access I can't get around with just implementing it right outta the box.
Custom row source for combo box in continuous form in Access
However, I refresh the form when evver I click on Control 2 or 3, it will refresh the rowsource for that control to use the value in the current record's Control1. That seems to be working!

Selecting a record in Access Subform

I have a form in Access 2003 that contains 2 subforms. The first is in datasheet view and is only 2 fields, SiteID and SiteName, so a list of many sites for one record in the parent form. The second subform is the same datasource as the first, but in single form view, so it shows all the site fields for one site in a single form. The idea being that I have a list of the site names on the left and I want to then click on one and have its OnCurrent event filter the subform on the right to show all the fields in that record (for that site).
This seems like a fairly simple thing to do but I can't figure out what code (docmd.gotorecord?, filter?, programatically change the subforms query and then requery etc) is the best to use... and how to make it actually work.
Any help appreciated.
Have a look at the Customer Orders form in the Northwind sample database (NWind.mdb) that ships with every version of Access or can be downloaded http://www.microsoft.com/downloads/details.aspx?familyid=c6661372-8dbe-422b-8676-c632d66c529c&displaylang=en
I think you will find it does what you want.

MS-Access unbound ComboBox in DataSheet?

In ms-access 2007, i'm trying to make a form for a table. this table has foreign keys from 2 parent tables. so i thought i would make these fields a lookup. but i couldn't create a single lookup for each parent table because they are composite keys.
I decided to create a query in which for each of these parent tables and the child table with an extra field for each composite key. this works fine with a normal form using an unbound ComboBox... but the unbound ComboBox does not work in a DataSheet Subform. when i make changes to a ComboBox in the Subform code, they are applied to all the other ComboBoxes in the same column as well.
My questions:
is there a way to change the values of the individual unbound ComboBox?
is there a different control i should be using other than the ComboBox or the DataSheet Subform?
what is the normal work around for this situation?
I cannot bind the ComboBox's because the field from the query is calculated/an-expression as I said.
I ran across a form of this problem myself, so for the sake of posterity:
While generally, the advice "Don't use continuous forms/datasheets in this situtation" is the best advice...It is possible to work around this.
However, access will not let you update the value of a single control on a datasheet. What can be used instead in this case is a temporary table, which can, when used as a recordsource, become the values of those controls. You will need to repopulate the table, and requery the controls (requerying the entire form should work as well) every time the calculation needs to change, however. Furthermore, should you enable editing on the controls, you will have to write some VBA on each control to handle the update event (Before Update), and run your own query to update the source tables, not merely the temporary table. Annoying to do perhaps, but effective.
There is another possibillity, which may also work, but I haven't tried to do something quite like this myself. The rowsource of a combobox can be very complex, so it is probable that you do not need to update the comboboxes with VBA at all. The rowsource can depend on other controls (such as another combobox) using the syntax Me.Form!controlName or Forms!FormName!ControlName, which will allow you to form the composite key. Of course, you can also select from queries with a rowsource. What is more interesting is that queries can reference controls on your form, provided the form is open, and you should safely be able to modify that with VBA should you have to.
Between the two of these, you should be able to force access, kicking and screaming, to display any data you wish, even on a datasheet, and to allow the user to change that data (but only if you want it to), and using the BeforeUpdate event, drag modified data back to whatever table it came from.
Continuous forms and datasheets do not work well for editing in situations where combo boxes need to be changed conditionally. The problem is that if you use the OnCurrent event to set the Rowsource of the combo box, it will be OK for that row, but will then hide the stored values for other rows.
The solution is to never use continuous forms/datasheets for editing data when this is the case (I hardly ever use them for editing, in fact). You can create two subforms, a continuous/datasheet subform that functions as a list, and a detail subform, that displays one record. Make the list subform uneditable, and the detail subform editable. You can link the two of them by using the Link Child/Link Master property of the detail subform control, and set it to the PK of the list subform.
If your list subform is Me!List and your detail is Me!Form, and the PK field is MyID, your link properties for the detail subform would be:
Master: Me!List.Form!MyID
Child: MyID
When you move to a different record in the list form, it will be automatically loaded in the child form. Any edits to the previously displayed detail will be saved before record departure.