Entering fields for songs database in Microsoft Access - database

I'm very new to Access. What I'm trying to do is create a database for songs which I will use to automatically create PowerPoint slides.
Most of the songs will be in Chinese, and the database will contain fields such as song name, number of characters in song name, number of strokes of first character of song name, verse 1 lyrics, verse 2 lyrics, chorus 1 lyrics, chorus 2 lyrics, etc.
I have an Excel file with the first column containing single characters and the second column containing the number of strokes of the character. I've imported this into Access as a table.
How do I get Access to automatically fill in the "number of characters in song name" and "number of strokes of first character of song name" fields for a record once I fill in the "song name" field?
I would prefer editing the database directly without using forms.

If you create a Query then use a Calculated Field.
You can use LEN to get the Length of Field.
You could use the SPLIT function to split your song name on spaces then get the len of the first item.

Related

How to read a flat file and load it into 2 different SQL tables(different table structure) using SSIS 2019

I have a flat file which doesn't have the header record. The data except the trailing record is like a fixed width flat file with no delimiters.
Data in flat file looks like:
TOM ROLLS
DAVECHILLS
TOTAL2XYZ
Fixed Width data(first 2 lines as shown in the above flat file data)
ColumnName Start position End position
Name 1 4
Last_name 5 9
I want to load the data(till trailing record) in data_table and the trailing record(starting with Total) in another table. The data in the total table should look like
c1 c2
2 XYZ
For the data table, I am currently using "fixed width" and dividing the data into different column and it is working fine. Can you please help to load this last trailing record in a different table(Total table as discussed above)
You have not provided enough data for me to test because I can find several methods to load one row and accomplish what you are asking but those methods not necessarily work with multiple rows depending on the structure of you source data.
On the surface it appears that you simply need to make another flat file connection and define the starting and end position to extract only the data for the second table.

Counting rows per special character in SQL Server

I have identify records that contain non-Alpha characters. I know how to do that part. I am using first and last name fields. The odd part of this is that I have to provide a count of rows per character. So for example, 500 rows contain $, 400 rows contain &, and so on. Dashes are Ok, and periods are ok if they are contained in a suffix. Is there any good way to pull and display this in a table format? Maybe a column that contains the characters and then a second column that has the counts of records that contain that character. I am on SQL Server. Thanks!
Here is an example of the output I am looking for.

I want Access to automatically enter a very specific data in a new field I created, the data will come from an existing field in the same table

This is related to MS Access 2016. I have a field called Name in which I have a long string. Every record in the Name field has an year mentioned in it along with some string. The year is always mentioned in paranthesis for example.
The story of a dead girl (1987) by Jack Ding
3 days of necro (2007) on water
etc...
I want to create another field called year in which I just want to add the year of that record automatically. I also want to delete everything after and including the year information in the Name field from every record. so in the above example I want to delete the string '(1987) by Jack Ding' and '(2007) on water' from the respective records.
I know I can just type it or Copy/Paste info from Name to Year but I have 4000+ records and I want to build a Query or Expression or Macro or whatever (I seriously don't know what) that will take only the year Info from Name field and put it in Year field automatically and delete everything after the year that is mentioned in the Name field (including the year itself)
Any Help will be appericiated
THANKS
You can use this in sql or vba, but this expression should output the correct value assuming there is only one open parentheses in any single string (though there are workarounds if there are multiple):
MID([Name],InStr(1,[Name],"(")+1,4)
The InStr function searches [Name] for the first open parentheses and returns the position of that character in the string. Mid extracts a specified number of characters from a string, but you have to tell it where in the string to start. Nesting them together, InStr tells Mid to start extracting at the position of the first open paren, +1 character, which should be the first digit of the year. Then Mid takes the 4 digits from that starting point and returns the string.
If your year field is a date data type, you may improve the expression by wrapping it in CDate which converts a string to a date data type.
You can write an UPDATE query using this expression to add the year for each record into the year field in the table:
UPDATE MyTableWithName&Year
SET Year = CDate(MID([Name],InStr(1,[Name],"(")+1,4));
EDIT: I missed the delete portion of your question. As you can see, InStr can be used to identify the position of your first open parens, so it can be used the same way with the LEFT function to truncate everything but the title. So the expression would be something like:
LEFT([Name],InStr(1,[Name],"(")-1)
You can then use that in a second UPDATE query (I would do these consecutively, since we don't want to truncate before the year is extracted) SQL code would be:
UPDATE MyTableWithName&Year
SET Name = LEFT([Name],InStr(1,[Name],"(")-1);

Vlookup array multiple columns

Excel wiz's,
I'm trying to build a report with a simple drop down list of names. Rather than try to explain in more detail, let me give you a sample dataset:
Table1:
Text Person1 Person2 Person3
String here contains name(s) Mike Smith Robert Johnson Suzy Q
Another string with name(s) Dan Boy John Michael Bob Wise
Different string with name(s) Robert Johnson Suzy Q
In my report sheet, I have a drop down list of all the possible "persons" that I want to chose from and then return all values from the "Text" column in an array. I have been able to make it work with only one column using this formula, where C4 contains my choice in the dropdown list:
INDEX(Table1[#All],SMALL(IF(Table1[Person1]=$C$4,ROW(Table1[Person1])),ROW(1:1)),1)
The text column will contain all the names of the Person columns, but they are in a different case (all caps, can't change format for display purposes). Maybe a SEARCH function would be more useful? I'm not sure. I'm trying to avoid using a macro, but I am not completely opposed.
Let me know what you guys think, and thanks in advance!
Simply re-organize your table so that there's one row per name... the V-Lookup on the name and get the matching list.
Person Text
Mike Smith String with names
Robert Johnson String with names
Suzy Q String with names
Dan Boy Second string with names
are you trying to make validations for teams? like select team, then next drop down gives only members of that team?
you can use offset inside validation. in one cell put a validation for the list of teams. in the other cell, create a list validation, use a offset formula to return the range of members based on the selected team.
edit: not sure how to put in a table, but this is how you would fill a range with vlookup
in the table with the entries, add a column with serial number starting from 1-n
just below the drop down box, enter numbers 1 to n in order
vlookup the serial number in the table, that is the row you are looking up
for the column, use a match to look in the table which column the current selected person is
drag the formula down to fill n numbers

The FREETEXTTABLE on MS SQL 2012 returns strange ranks

I try to find several words in one table but in different fields.
Why the records with one corresponing word have the rank higher than the records with two ones?
The example:
Record 1
Title: Eddie Murphy
Description: An American stand-up comedian, actor, writer, singer, director, and musician.
Record 2
Title: Tom Cruise
Description: An American film actor and producer. He has won three Golden Globe Awards.
SELECT * FROM FREETEXTTABLE(SubjectContent, (Title, Description), 'tom actor')
returns Recrod 1 with rank 61 and Record 2 with rank 47 despite the record 2 contains both words ('tom' and 'actor') and record 1 contains only one word ('actor'). So the user receives the huge amount of unproper records before the proper one.
Though if I set the search parameter 'tom cruise actor' the request returns the high rank.
My fulltext index:
CREATE FULLTEXT INDEX ON SubjectContent(Title, [Description])
KEY INDEX PK_SubjectContent
ON FullTextSearch;
I unsuccessfully tried to change the property 'accent sensitive' and other properties of Full Text Catalog. Thanks for any help.
Looking at the 2 strings, I see that the second one is a larger document from fulltext point of view. this is because of the sentence separator you have in there. So if you pass these strings to the dm_fts_parser, you will see that the max occurrence of first string is 11 and second one is 21. Fulltext normalizes this document length in buckets of 16, 32, 128, 256 .. etc. so your first document falls in first bucket and the second in second bucket. hence first one has higher rank (inversely proportional to the length of the document). reference of all this is here http://msdn.microsoft.com/en-us/library/cc879245.aspx
Thanks
Venkat

Resources