I have a table person (id omitted):
first name | last name
----------------------
peter | parker
mary jane | watson
J Jonah | Jameson
And I have a table course:
course name | attendees
------------------------------
Chemistry | peter; J Jonah
Photography | peter; mary jane
I used the "Nachschlage-Assistent" (sorry for german, I don't know the original term) to connect the attendees-column to store multiple persons. Now Id like to change, how the Persons are displayed in this cells, preferably in a report:
course name | attendees
-------------------------------------------
Chemistry | Peter Parker, J Jonah Johnson
Photography | Peter Parker, Mary Jane Watson
How can I achieve this?
What you used was "Lookup Wizard" to create a lookup field in table. Then the field was set to allow multiple values. This is a multi-value field (MVF). Advise not to build lookup fields in table nor to use multi-value field.
If attendees field is actually saving ID (as it should) and displaying first name, modify combobox RowSource property SQL statement to:
SELECT ID, StrConv([first name] & " " & [last name], 3) AS FullName FROM person;
StrConv() function will convert text to proper case so first letter of each word is capitalized and others are not. This is not a perfect solution because "mcdonald" will become "Mcdonald" instead of "McDonald" and "von der heide" will be "Von Der Heide" instead of "von der Heide". For more info review http://www.fmsinc.com/microsoftaccess/query/action-queries/proper-case/index.htm
Also advise not to use spaces nor punctuation/special characters in naming convention.
Related
the first is the sectors table that has an id and sector name like this
id | sector
1 | Government
2 | Education
The second is the employee table like this (simplified)
Id | name
1 | sam
2 | tom
Finally I have a sectorMap table (this is used to join the two tables above together) like this
Id | sectorid | employeeid
1 | 1 | 2
2 | 1 | 1
3 | 2 | 2
So in this instance, once I join everything together and view the sectors or each employee, it would show that tom has two sectors (government, education) and sam only has one (government)… hope that makes sense
My question is, within my application, the user has the ability to change these sectors by selecting from a multiple selection dropdown in html. For some reason I thought that by doing an update on duplicate expression would work, however seeing how I have multiple rows of data, I would need to delete all rows within the sectormap table that do not reflect the new selection and contain the selected employees id. What would be the best way of going about that?
For instance, in this case, lets say I open the application and see that tom has two sectors tied to him (government, education) and I only wanted him to have one (government). When I deselect education and select GO. The application returns a list to the server that contains (‘government’). How can I formulate an expression to delete the education sector row from the sectormap table that contains his id?
Your answer is in your question.
1st when you are deselecting education. You will get data of (‘government’). right?
So just invert your query. select those records which is not (‘government’), those are education.
So, education records are you can delete.
Hope this will help you. thanks:)
How can change the presentation of the data so I get the names o the princesses by two columns, shown in "Wanted output". Column grouping on Knight's name gives me a Princess column for each of the princesses names. I only want two columns since I know that a knight will never have more than two princesses.
The the data I get from my input source is shown below as "Input data". Unfortunately I cannot use SQL to manipulate the data, since the QUERY is based on FetchXML. The only tools I can use is what I'm getting from Reporting Services (I'm using Visual Studio 2015), so have that in mind while suggesting any solutions.
Technically thers's a 1:M relation between Knight and Princess, but there's a restriction in the system so that a knight will never have more than 2 princesess. A Knight can have 0, 1 or 2 princesses.
Input data
_________________________________
| Knight | Princess |
|_______________|_______________|
|_____Adam______|_____Anna______|
|_____Adam______|____Angelica___|
|_____Erik______|_____Erika_____|
|_____Erik______|______Eva______|
Output
_________________________________________________________________________________
| Knight | Princess 1 | Princess 2 | Princess 3 | Princess 4 |
|_______________|_______________|_______________|_______________|_______________|
|_____Adam______|_____Anna______|_____Angelica__|_______________|_______________|
|_____Erik______|_______________|_______________|_____Erika_____|_____Eva_______|
Wanted output
_________________________________________________
| Knight | Princess 1 | Princess 2 |
|_______________|_______________|_______________|
|_____Adam______|_____Anna______|___Angelica____|
|_____Erik______|_____Erika_____|_____Eva_______|
Any suggestions?
You can do this by using choose and lookupset on the dataset:
=Choose(1,LookupSet(Fields!Knight.Value,Fields!Knight.Value,Fields!Princess.Value,"InputData"))
=Choose(2,LookupSet(Fields!Knight.Value,Fields!Knight.Value,Fields!Princess.Value,"InputData"))
=Choose(3,LookupSet(Fields!Knight.Value,Fields!Knight.Value,Fields!Princess.Value,"InputData"))
etc.
In each column.
This is almost impossible, but you have lucked out by having a (quite reasonable) limit of 2 Princesses per Knight. Any more and you would be stuck.
I would use an Table, not a Matrix object for this. First column is the Knight.
The next column has a static Header "Princess 1", with expression:
=Min(Fields!Princess.Value)
The 3rd column has a static Header "Princess 2", with expression:
=Iif ( Min(Fields!Princess.Value) = Max(Fields!Princess.Value) , "" , Max(Fields!Princess.Value) )
You could make a table with a rowgroup by Knight and within that rowgroup body add a tablix with a columngroup by Princess. Only problem would be, that the column headers Princess 1..x would have to be somehow hard coded into the underlying table.
NOTE: I dont want to remove the repeating node, more like merging them.
I have a view that pulls a seminar content type along with the taxonomy term attached to the content type. In the content type the term reference field pulling the taxonomy term is a multivalue field. So whenever there is more than one taxonomy term attached to the node the view result is repeated. So using view and its api what I want is
What I have now when view pulls the result is
Nid Speaker name | Location | Time
----------------------------------
12 Sanjok Gurung| London | 1900
11 John | London | 1900
10 Sally | London | 1900
10 Molly | London | 1900
So the above table, Sally and Molly are term reference selected in the same node.
What I want is
Nid Speaker name | Location | Time
----------------------------------
12 Sanjok Gurung| London | 1900
11 John | London | 1900
10 Sally,Molly | London | 1900
I tried manipulating the results from views_pre_render but this method feels like it is so dirty. There should be a better clean solutions
You need to use this contrib module.
URL: https://www.drupal.org/project/views_aggregator
You can read the documentation from the below url. http://cgit.drupalcode.org/views_aggregator/plain/README.txt?id=refs/heads/7.x-1.x
This is not a view issue actually,
If you open the Manage Display of seminar content type and try to edit the display settings of entity reference FORMAT format drop-down select separator you can change what kind of separator you may want to choose from settings tab like (comma or dash)
Note: Make sure to edit the exact display mode (teaser or Full content or Default) which ever is used in the view.
May be this will resolve the issue.
I am completely new to Access, but I've done the tutorials, and have some VBA experience with Excel, so I shouldn't be hopeless.
I haven't progressed to forms yet, right now I'm focusing on getting the tables defined and populated, and relationships defined.
I've changed the actual tables in the example here, but the context and problem hold.
Table 1 is Food. Other than the autofield key, it has two fields
FoodCat FoodType
Fruit banana
Fruit apple
Fruit pear
Meat lamb
Meat beef
Meet Chicken
Vegetable Broccoli
etc....
This table is used by another table, in a lookup and relationship setup.
It is easy to set it up so the other table has a field that is restricted to entries with the items in the FoodCat Field (although it is repetitive). I can also restrict the next field to entries with the FoodType Field, but this gives me all the choices.
What I'd like to do, in the new table, is restrict the FoodType choice to the entries that have a matching FoodCat choice.
So, if the item selected on the new table under FoodCat is Meat, I only want the FoodType choices to be lamb, beef, or chicken.
Is this even possible within the table? Do I need to use Forms to get this done?
Answering to your comment:
When you use "Lookup" fields" you are forcing a new relation between the tables.
The best way to avoid the problems listed in the Ten Commandments of Access (specifically: The evils of the lookup fields in tables ) is to create the relations manually, and then use them to create the adequate "lookup" control in a form or report.
Let's say you have the following tables:
tblCategories
id | catName
---+-----------
1 | Fruit
2 | Meat
3 | Vegetable
tblFood
id | idCat | foodName
---+-------+-------------
1 | 1 | Apple
2 | 1 | Banana
3 | 2 | Lamb
4 | 2 | Beef
5 | 3 | Broccoli
In this example is obvious that there's a one to many relation between these two tables, and that the idCat field in tblFood is a foreign key. You can create this relation by hand in the "Relations" window.
With the following query you can get both the foodName and catName fields properly (a good thing to build reports):
select f.*, c.catName
from tblFood as f
inner join tblCategories as c on f.idCat = c.id;
This would throw something like this:
id | idCat | foodName | catName
---+-------+----------+------------
1 | 1 | Apple | Fruit
2 | 1 | Banana | Fruit
3 | 2 | Lamb | Meat
4 | 2 | Beef | Meat
5 | 3 | Broccoli | Vegetable
which is a nice and useful query that you can use in a report... without the need of using Combo Boxes in the report.
So: How on earth to build a control, for example, a ComboBox, that filters only the foodName values depending on a catName value?
First: Create the form
Then: Create a Combo Box and put this in the RowSource property:
select id, catName from tblCategories
Set the control to have two columns, and column widths: 0, 10. This will make the id column in the drop-down list "invisible". Be sure to know the name of this combo box (let's say it is named comboBox01).
Now, create a second combo box, keep the RowSource property empty, and set the column widths to 0, 10. Also be sure to know the name of this second combo box (let's say it is named comboBox02).
And now let's make VBA do what you need: On the properties sheet of the comboBox01 control, look for the afterUpdate event, clic on the ellipsis button, select "VBA code" and write the following
Sub comboBox01_afterUpdate() ' This is added automatically by the VBA editor
strSQL = "select id, foodName from tblFood where idCat=" & comboBox01.Value
comboBox02.rowSource = strSQL
comboBox02.Requery
End Sub ' This is added automatically by the VBA editor
"Lookup controls" (no "lookup fields") are very useful when used in forms. They can save a lot of headaches to the users of your database (you included). But I strongly recommend you to avoid creating them directly in the tables.
Hope this helps.
Yes, it is possible to do within the table. However, it's easier to do through a form and it's more practical to do through a form. You NEVER, EVER want your user interacting directly with a table.
So I have this list of 230 countries already in my database table called "countrylist" inside the "country" row. besides the "country" row, I also have the "code" row, which has the country code of that country in it.
The countries are in English and since I need the country names in 3 other languages as well, I duplicated the table for the 3 other languages too. I also programmed the PHP code to choose the right table based on the language.
I have the list of the country names in the other 3 languages ready and they have the same ordering.
BUT... this leaves me with 230 countries to replace in 3 languages, and that's a lot of wasted time for something which I already know should be much simpler than basic copy pasting. Although I don't even have a slight clue of how or if this can be done...
I want to know if there is a way to preserve the "code" row in the tables and replace all of the countries in the "country" row with a query/command?
Thanks, any help is much appreciated
INSERT INTO countries_fr (code) SELECT countries_en.code FROM countries_en
Assuming you have the tables countries_fr and countries_en, and both have the code column.
This will insert all the code from the countries_en table into the code of countries_fr table.
You create a relational model.
country (id, name)
countryLang (countryId, lang, translatedName)
This way, the languages are independent of your parent country name.
| ID | NAME | COUNTRYID | LANG | TRANSLATEDNAME |
---------------------------------------------------
| 1 | Poland | 1 | en | Poland |
| 1 | Poland | 1 | pl | Polska |
See a demo
So it's normalized, you have to add columns for the other 3 names in the table, so (replace the languages with those desired):
alter table countries add french varchar(45),spanish varchar(45),russian varchar(45);
Since the code is exactly the same you can use it like a key field this one time.
update countries c set c.french=(select country from french where french.code = countries.code),
c.spanish=(select country from spanish where spanish.code = countries.code),
c.russian=(select country from russian where russian.code = countries.code);
On the other hand...
If you were to simply replace the country name you would have to maintain 4 sets of code.
update countries set country=(select country from language2 where language2.code=countries.code);
None of the answers were practical due to the nature of the code from before, so I had to redo everything manually with Dreamweaver copy and replace. Took an hour but it was done right.