MS Access Form Not Showing Results - ms-access-2010

This is truly baffling.
I have a subform that is set up as a continuous form and receives data from a query. Here is the SQL
SELECT Top 12 Tbl_Parent_ITN.ID, Tbl_Parent_ITN.ITN_Number, Tbl_Child_ITN.ITN,
Tbl_Child_ITN.Parent_ITN_fk, Tbl_Scope_Rqmts.Completed, Tbl_Scope_Rqmts.Child_ITN_fk,
Tbl_Lkup_Requirements.Requirement, Tbl_Lkup_Basis.Basis
FROM Tbl_Parent_ITN INNER JOIN (Tbl_Lkup_Requirements
INNER JOIN (Tbl_Lkup_Basis INNER JOIN (Tbl_Child_ITN INNER JOIN Tbl_Scope_Rqmts
ON Tbl_Child_ITN.Id = Tbl_Scope_Rqmts.Child_ITN_fk) ON Tbl_Lkup_Basis.ID = Tbl_Scope_Rqmts.Basis_fk)
ON Tbl_Lkup_Requirements.ID = Tbl_Scope_Rqmts.Requirements_fk)
ON Tbl_Parent_ITN.ID = Tbl_Child_ITN.Parent_ITN_fk
WHERE (((Tbl_Parent_ITN.ID)=[Forms]![Frm_Parent_ITN_Main]![parent_id]));
The criteria in the where clause of the SQL is passed based on the control in the form that precedes this form. The value is the primary key of the parent table that joins with several child tables to get all of the data for the subform.
When I open the with one record that has children it works perfectly fine and the form populates with 12 records. However, when I go run the same operation on the next parent record I don't get any results in view even though that parent has 4 child records.
What is really perplexing is that when I run the query independently from opening the form it gives me the exact results that I want based on that 2nd parent record. Furthermore, if I change the subform to a datasheet I still don't get any records; however, I can see the results in the filters of the datasheet form if I select those column headers (but no records show in the form itself). The properties of the subform are the exact same in both cases, so I can't understand what would cause the records to show in the 1st case but not the 2nd??

A few suggestions:
1. Try to do a Me.Refresh to see what happens.
2. Put a break point in the form's OnError event to see is there is something wrong.
3. Check if there is any other data source that may be locking any data that should be refreshed.
4. Verify that the no properties that define the parent-child relationship of the data is being changed during runtime.
5. Check if the parent record id gets refreshed on the OnCurrent event of the form.
Hope this helps,
FunkSoulBrother

Related

How can I set the values of select lists if one of them is the Parent LOV of the other?

I have two select list : A and B.
A is the parent LOV of B. So when A changes B gets refreshed and changes based on the value of A.
--> B now has lower values to chose from.
Now my problem is that when I select values via PL SQL into the select list (from the database) that select list B never returns the wanted value but the values I would get when I choose the value from A.
--> B should be set to John and A should be set to IT.
--> B returns null value but I can choose all people that work in IT.
When I remove A as Parent LOV then the right value is inserted into B but the list dosent adapt to A.
I use Oracle APEX v.19.1.0.00.15
So I tried it out myself.
I had a button that triggers a Dynamic action. The action was PLSQL code and it just assigned the parent and child. If I set it to assign both of them in the same action, it didnt work, if I separated them out it did.
So change out the actions in your DA(dynamic action) first you have a PLSQL action that assigns the parent item, and you also need to set the Items to return to return this item. Then you have a second action that is the same thing, just for the child.
This works for me, so I am hoping it works for you, let me know if it is still causing you issues

How to show all items in Listbox that is linked to dropdown

In an Access Userform I have a listbox that is linked to a dropdown field. In the dropdown field the user can choose a country, and the listbox then updates and shows only the records that are relevant to that country.
I have described how I get the listbox to filter based on the selection in the dropdown in this question here.
While I managed to solve one problem there I created another.
Now when I open the form, the listbox is empty instead of showing all records.
My question: How can I show all records in the listbox to begin with and THEN have the user filter the list based on the dropdown?
The SQL Code in the LIstbox is now the following:
SELECT tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR, tblISIN_Country_Table.Country
FROM tblFUNDS INNER JOIN tblISIN_Country_Table ON tblFUNDS.ISIN = tblISIN_Country_Table.ISIN
GROUP BY tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR, tblISIN_Country_Table.Country, tblFUNDS.Fund_Selection
HAVING (((tblISIN_Country_Table.Country)=[Forms]![frmMain]![ddnCountry].[Text]) AND ((tblFUNDS.Fund_Selection)=0));
So I ended up solving this one as well... with a bit of help from an online article which I can now no longer find unfortunately (otherwise I would reference it here):
SELECT tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR, tblISIN_Country_Table.Country
FROM tblFUNDS INNER JOIN tblISIN_Country_Table ON tblFUNDS.ISIN = tblISIN_Country_Table.ISIN
GROUP BY tblFUNDS.MorningsStar_Fund_Name, tblFUNDS.ISIN, tblFUNDS.RDR, tblISIN_Country_Table.Country, tblFUNDS.Fund_Selection
HAVING (((tblISIN_Country_Table.Country) Like Nz([Forms]![frmMain]![ddnCountry].[Text],'*')) AND ((tblFUNDS.Fund_Selection)=0));
The important part is this...
Like Nz([Forms]![frmMain]![ddnCountry].[Text],'*')) AND ((tblFUNDS.Fund_Selection)=0));
Essentially the Nz function lets you return a value when a variant is null. I had it return * which ofcourse is the SQL equivalent of Return All.

Choosing from multiple query results to display in a single form

I have a form that submits parameters to a query, then opens the resulting record in another form. The problem is, whenever there is more than one record it automatically puts the first one into the from without any kind of option to choose the record I want. I have a macro set up on the search button on the first form that submits the parameters to the query and then displays it in the second form, I've tried to set up another macro in between the two, but I don't know if it's possible to set up the expression creator to check the number of rows resulting from a query. Is it possible to modify the query to create a prompt to choose which record I want? Or should I change something else?
This is the query:(automatically created by access)
SELECT CHILD.CHILD_L_NAME, CHILD.CHILD_F_NAME, CHILD.DOB, CHILD.GENDER, CHILD.DAYS_IN_CARE,
CHILD.HOURS_PER_DAY, CHILD.ENROLLMENT_DATE, CHILD.CHILD_ADDRESS, CHILD.CHILD_CITY,
CHILD.CHILD_ZIP, CHILD.CHILD_STATE, CHILD.CLASSROOM, CHILD.SNACK, CHILD.LAST_UPDATED, CHILD.CIN
FROM CHILD
WHERE (((CHILD.CHILD_L_NAME)=[Forms]![Search]![L_NAME]) AND
((CHILD.CHILD_F_NAME)=[Forms]![Search]![F_NAME])) OR
(((CHILD.CHILD_L_NAME)=[Forms]![Search]![L_NAME]) AND
((CHILD.DOB)=[Forms]![Search]![DOB])) OR
(((CHILD.DOB)=[Forms]![Search]![DOB])) OR
(((CHILD.CHILD_L_NAME)=[Forms]![Search]![L_NAME]));
If I understood well your problem and you use VBA it's quite easy to do.
You can create a reduced query based on the query you're creating with the button. This new query should include all and only the fields that allows you to discriminate beetwen the records to show in the 2nd form.
For instance it could include LastName, FirstName and classroom to select between children with same full name.
You can count the number of records of this 2nd query and if greater than 1 it means that you have more than one children to show.
So you can use this 2nd query to populate a combo-box or a listbox for selecting the record you really want to show.
When number of records is 1 you can simply skip the listbox population using an if statement on recordcount.
Next step is opening the form with the selected (or unique) record.
Bye

MS Access subform to query based form populating wrong

I'm working on an Access database that has a main table that keeps track of basic user information and several sub-tables that have a one-to-many relationship to the main. Now all users are in one of two groups, which they can move between, and half of the tables only apply to one group. Which group a user is in is determined by a Boolean.
How I intended to set up the the various forms and sub-forms was to have the main form based on the queries:
SELECT *
FROM Foo
WHERE InGroup1 = TRUE
and
SELECT *
FROM Foo
WHERE InGroup1 = FALSE
and then add the appropriate sub-forms.
However, what keeps happening is that if there isn't a record in the sub-table associated with the currently selected ID of the main table, it just displays the first record in the table.
If I make a main form not based on a query it works fine, but then the two groups are mixed together.
Is there a way around this?
I cannot reproduce your problem. This is an example of a form and subform where the subform data does not contain a record for the main form. The main form is based on a query:
SELECT * FROM groups WHERE ingroup1 = true
And is built in MS Access 2010.

ASP.NET DropDownList - How do I handle missing values?

I have a list of values in a SQL Table which are used to popluate a DropDownList, having a unique Integer as the value of each item and a String as the visible text (via SqlDataSource). There is also a third field in the database which is a flag to indicate whether the list item is active or not (inactive items are not shown in the DropDownList)
Selections made in the dropdown are stored in the database as their integer value (as part of a dataset making up the overall record), not the text value.
Over time, the items in the DropDownList may be removed by marking the items as inactive. However, there is still a need to open old records which may have had a now-inactive item as part of it's data...
My question is, what's the best way to ensure that the missing value included in the dropdown for the old record?
The two methods that spring to mind are to either:
Populate DropDownList with only the currently active items and, when loading a record, catch when the app tries to select a value that doesn't exist, go back to the db to see what it should be (the text value) and manually add it into the dropdown.
or...
Populate DropDownList with all list items (both active and inactive), load the record and then programatically remove all the inactive items (execpt for any that are now selected).
Neither of these seem particularly efficient, so I was wondering whether there is a best practice for this kind of thing?
there are so many optimum ways to do that sort of things, i am defining here a couple of them, use any of following if your Drop down list items count is less than 200 , lets say drop down list is of Products
1)
i) Load all Products records in drop down list and hide the inactive ones by setting visible=false
i) When you load a user record than look for its drop down list value if its visible than select it and enjoy, if its not visible than make it visible by setting its property visible=true and select it and also set its index or id in a flag to change its visibility(visible=false) again after your/users required operation performed.
2)
i) load only active Product records in drop down list ii) while loading a user record also load its product details(name, id, inactive_status) using Joins in sql.
iii) check in that user record if item is inactive then add its record in drop down list as you have all its details now with user details record else just select it.
IMPORTANT NOTE: if you drop down list has items in millions than use ADVANCE SEARCH techniques
The first thing I would do is question your business logic - should you be able to make an item inactive if it is being used as a foreign key in an active row elsewhere? If you make it inactive should it not remove all foreign keys as well?
To answer your question though I would go with a variation on the second idea but filtering in the page like that is probably slower than doing directly with SQL so I guess you have something like this at the moment to populate the dropdown
SELECT * FROM Table WHERE Active = 1
You should already have your record and the foreign key value so I would change it to this
SELECT * FROM Table WHERE Active = 1 OR PrimaryKey = [YourForeignKey]
Then you will always have the selected item but should also be fairly efficient.

Resources