ms access form listbox changing whole field - forms

I have created a form to update a query that that is in turn based on a master table containing information on a number of files. This master table is then related to several other tables in say for example a table called group_table, defining which group the file would belong to, which contains an ID field and the group_name. This is then related in a one-to-many relationship with the master table based on the group.ID and a field in the master table master_table.group and joined in the query the form is based on.
In the form I have designated a listbox control to update the group field of the query/master table. The contents available for selection in the list box were set based on the group_name field from the group_table table which is defined in the RowSouce section of the property sheet of the form.
So my issue is that when I try and update any records in the query using the listbox in the form, all of the records that are the same will get changed as well. E.g., changing a record in one row from "Group A" to "Group B" will change all the records containing "Group A" to "Group B" in the group field. So I was wondering if there is anything I can do to set it so only the specific record that I want to change gets changed.

When you are making the call to update the table you should make sure that you are using WHERE along with the primary key to make sure that you update that row only. An example would be a statement similar to the one below.
CurrentDb.Execute "UPDATE [group_table] AS G INNER JOIN [master_table] AS M
ON G.[ID] = M.[groupID]
SET G.[group] = '"& Group A & "'
WHERE M.[groupID] = '" & groupIDFromForm & "';"
Apply the ON from the join so that the foreign key and primary key are going to share the same value, and from there use the form to create a variable that you can use to identify the exact row. From there the program should execute the query correctly.

Related

Enforce relationship match in FileMaker

I have two FileMaker tables that are linked using a relationship. The relationships matches based on the content of two fields:
TableA.Foo matches TableB.Foo
TableA.Bar matches TableB.Bar
Is there a way to enforce constraints on this relationship in FileMaker? When entering objects in TableA, I'd like to ensure that the values entered in fields Foo and Bar are such that there exists a corresponding record in TableB. Is this possible?
Bonus points if I could somehow autocomplete values of Bar based on the entries of TableB and the value already entered in Foo.
To answer your question as asked:
You can validate the Bar field (or any other field) by
calculation:
not IsEmpty ( TableB::Foo )
Set the validation to validate Always. This will throw a
validation error if you try to commit a record in TableA without
having a related record in TableB.
To auto-complete based on values in another field, you must format
the target field as Drop-down list with Auto-complete using a value
list.
Before defining the value list, set up a new relationship (using a
new occurrence of TableB) as:
TableA::Foo = TableB 2::Foo
Then define the value list to use values from TableB 2::Bar, show only related values starting from TableA.
I suspect there may be better ways to accomplish whatever you're trying to accomplish here.

Number each nested table inside a master table on a Jasper report

So i have the following issue. In my database I have a table named
bp_minutes_app.
This table stores records of minutes from committee meetings. Each minute can consist of many files. The database design regarding minutes is the following:
The table bp_minutes_attachments is connected via a foreign key to the bp_minutes_app and holds the following information:
description, createdby
The table
bp_files
is connected via a foreign key to the
bp_minutes_app
and holds the file along other information. We are interested in taking only the name and id of the file (the latter in order to create a hyperlink to the file, but this is out of scope of the present question).
Final remark. All those tables are linked to the master
bp_full
table that is joined only to get the id of each specific report.
In my report I want to print on a table all minutes and the accompanying information (file name, description, createdby, submission date), but make a separate entry for each minute. In order to achieve this, I first created a table that uses the following dataset:
SELECT bp_minutes_app.id
FROM bp_minutes_app
INNER JOIN bp_full ON
bp_minutes_app.bp_full_app_id = bp_full.id
WHERE bp_full.id = $P{id}
With this dataset I retrieve each minutes record. In my example, I get two records with ids 39 and 40.
Inside this table I nested another table to retrieve information for each file in each minutes record. The dataset that I used is the following:
SELECT bp_minutes_app.submission_date,
bp_minutes_attachments.createdby,
bp_minutes_attachments.description,
bp_files.id,
bp_files.name
FROM bp_minutes_attachments
left JOIN bp_minutes_app ON
bp_minutes_attachments.bp_minutes_app_id = bp_minutes_app.id
AND bp_minutes_app.id = $P{mid}
left JOIN bp_full ON
bp_minutes_app.bp_full_app_id = bp_full.id
left JOIN bp_files ON
bp_minutes_attachments.bp_file_id = bp_files.id
WHERE
bp_full.id = $P{id}
The id parameter is used again to take the specific report and the mid parameter to take a specific minute. On parameter specification mid is declared as follows:
mid = $F{id}
, where id is the bp_minutes_app.id.
Following this setup I managed to get nested tables for each minute (forgive me for the greek headers):
What I want to do is number each subtable from 1...n, according to the number of minutes/ subtables. How can I achieve this? I tried to create a suitable variable but it was not met with success. I want to somehow "save" in a parameter / variable the count of bp_minutes_app records and manipulate this number for each nested table header, instead of just numbering each table with the corresponding id.
Sorry for the long post but I am new to Jasper and I wanted to be clear about the steps I have taken and what I want to achieve.
Alot of sql not much jrxml in your post so I start by guessing.
Have you tried something like this in the jrxml:
<variable name="counter" class="java.lang.Integer" calculation="Count">
<variableExpression><![CDATA[$F{id}]]></variableExpression>
</variable>

Copy Field contents from one Table to another table - FileMaker

I am new to Filemaker pro. I am working with Filemaker pro 13.
My database contains 3 tables:
category (fields = _pkCatID & CatName)
subcategory (fields = _pkSubcatID , _fkCatID & SubcatName)
books (many fields including _fkSubcatID)
I have no problems in conditional value lists, so making two popup menus in books layout for categories and subcategories was successful.
But I want to put both categories and subcategories in one menu/sub-menu using 2empowerfm Menu Popper plugin.
I created a new field in subcategory table to store a calculation to be used in the value list of the plugin.
The calculation is = CatName & ">" & SubcatName & ";" & _pkSubcatID .
So the returned value when choosing in books layout will be "_pkSubcatID".
The problem is CatName is not in Subcategory table, and if I choose it from the related table Category, I can't make the calculation "stored" which is a requirement to use a field in a value list.
So, I need to copy the field CatName from category table to a new created field in subcategory table. I don't know how to do it.
You just need to create a lookup field in your subcat table pointed to the category name in the category table.
Create a field in the sub-cat table called "Category"
Click on Options
Auto-Enter Tab at the bottom, check "Looked-up value"
Select the correct starting (subcat) and related (Cat) tables and select the name field for the Category.
That is all.
To populate this for existing records click into the _fkCatID field on a subcat layout after showing all records and in the menus select Records->Relookup Field Contents
#Michael Wallace answer is correct and that solution should work.
I'd add however that if the table is likely to become large (and it could do if you're cataloguing books for a library) then I'd suggest you run some tests on a fake large data to see if this menu technique holds up (especially if you are serving over a network). Running two global search fields with an executeSQL lookup for subcategory within category would be more efficient in a big data set - this technique is well described here and other places:
http://forums.filemaker.com/posts/c4ed6f9923

Use Access replication id in form as number

I have a number of tables in an MS Access Db that have to use Replication IDs (GUID) as the primary key (and therefore also as foreign key contraints in the relationships between them). The data for these tables comes from an external application and I can't use any other field as a primary as they aren't unique. (I've also chosen, not to use local integer keys, "in loco parentis" for the GUID).
The database worked fine and all the relationships worked as expected and I am able to present the related records in a hierarchical MS Access form (one-to-many-to-many). The problem occurs when I try to present a count as part of the relationhips.
If I have GUIDInParent and GUID in Child as two fields, I can get the children by creating a form with Source Object = ParentToChildRelationship and Link Master Field = GUIDInParent and Link Child Field = GUIDInChild.
However, if I want indicate how many Chidren I'm going to display (since they may be hidden under a scrolled section), I use a separate form field populated via a DCount("1", "ParentToChildRelationship", "[GUIDinChild] = '" & [GUIDInParent] & '")
For the GUID field - this doesn't work... The reason appears to be that while on the form, the GUID (Replication ID) displays as a "GUID" - of the form "{HHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH}" when assigned to another field it (literally) displays as "Chinese". Even assigning via the GUIDAsString function doesn't change this.
What's going on an is there any way I can use these GUIDs as I intend?
I have "jury rigged" a solution by having two columns in the tables (GUID - as number and GUIDString - as string) both set tot he same value and using the rendering that works in each case...
The DCount("1", "ParentToChildRelationship", "[GUIDinChild] = '" & [GUIDInParent] & '") thus becomes:
DCount("1", "ParentToChildRelationship", "[GUIDinChild] = '" & [GUIDInParentString] & '")
and thus works...
TIA,
Paolo
Have you considered a control in the subform footer to count the records? This can be referenced in the main form by name. Alternatively, you can refer to MySubformControl.Form.Recordset.Recordcount

Create a new FileMaker layout showing unique records based on one field and a count for each

I have a table like this:
Application,Program,UsedObject
It can have data like this:
A,P1,ZZ
A,P1,BB
A,P2,CC
B,F1,KK
I'd like to create a layout to show:
Application,# of Programs
A,2
B,1
The point is to count the distinct programs.
For the life of me I can't make this work in FileMaker. I've created a summary field to count programs resetting after each group, but because it doesn't eliminate the duplicate programs I get:
A,3
B,1
Any help much appreciated.
Create a a summary field as:
cntApplicaiton = Count of Application
Do this by going into define fields, create a field called cntApplication, type summary. In the options dialogue make the summary field a count on application
Now create a new layout with a subsummary part and nobody. The subsummary should be sorted on Application. Put the Application and cntApplication fields in subsummary. If you enter browse mode and sort by Application you ought to get the data you want.
You can also create a calc field with the formula
GetSummary(cntApplication; Application)
This will allow you to use the total number of Applications with in a record
Since I also generate the data in this form, the solution I've adopted is to fill two tables in FileMaker. One provides the summary view, the other the detailed view.
I think that your problem is down to dupliate records and an inadequate key.
Create a text field called "App_Prog". In the options box set it to an auto-enter calc, unchecking the 'Do not replace...' option, and use the following calc:
Application & "_" & Program
Now create a self join to the table using App_Prog as the field on both sides, and call this 'MatchingApps'.
Now, create (if you don't alread have one) a unique serial number field, 'Counter' say, and make sure that you enter a value in each record. (Find all, click in the field, and use serial number option in'Replace Field Contents...')
Now add a new calc field - Is_Duplicate with the following calc...
If (Counter = MatchingApps::Counter; "Master Record" ; "Duplicate")
Finally, find all, click in the 'Application field, and use 'Replace Field Contents...' with a calculation to force the auto-enter calc for 'App_Prog' to come up with a value.
Where does this get you? You should now have a set of records that are marker either "Master Record" or "Duplicate". Do a find on "Master Record", and then you can perform your summary (by Application) to do a count of distinct application-program pairs.
If you have access to custom functions (you need FileMaker Pro Advanced), I'd do it like this:
Add the RemoveDuplicates function as found here (this is a recursive function that takes a list of strings and returns a list of unique values).
In the relationships graph, add another occurrence of your table and add an Application = Application relationship.
Create a calculated field in the table with the calculation looking something like this:
ValueCount(RemoveDuplicates(List(TABLE2::Program)))
You'll find that each record will contain the number of distinct programs for the given application. Showing a summary for each application should be relatively trivial from here.
I think the best way to do this is to create a separate applications table. So as you've given the data, it would have two records, one for A and one for B.
So, with the addition of an Applications table and your existing table, which I'll call Objects, create a relationship from Applications to Objects (with a table occurrence called ObjectsParent) based on the ApplicationName as the match field. Create a self join relationship between Objects and itself with both Application and Program as the match fields. I'll call one of the "table occurrences" ObjectsParent and the other ObjectsChildren. Make sure that there's a primary key field in Objects that is set to auto-enter a serial number or some other method to ensure uniqueness. I'll call this ID.
So your relationship graph has three table occurrences:
Applications::Applicaiton = ObjectsParent::Application
ObjectsParent::Application = ObjectsChildren::Application, ObjectsParent::Program = ObjectsChildren::Program
Now create a calculation field in Objects, and calculating from the context of ObjectsParent, give it the following formula:
AppCount = Count( ObjectsChildren::ID )
Create a calculation field in Applications and calculating from the context of the table occurrence you used to relate it to ObjectsParent with the following formula:
AppCount = ObjectsParent::AppCount
The count field in Objects will have the same value for every object with the same application, so it doesn't matter which one you get this data from.
If you now view the data in Applications in list view, you can place the Applications::Application and Applications::AppCount fields on the layout and you should get what you've requested.