Access Dynamic entry form - ms-access

First off my Access skills are sub-par, but I'm fairly certain that it is the direction I need to go for my project so I'm hoping I can get some feedback to direct my research. I am however well versed at Excel, VBA and Matlab so I'm not completely incapable, I hope.
I need to assemble a system to track emissions (chemicals) from a variety of sources (units). Each unit has its own set of possible emissions and they need to be tracked daily (but also have the capability to be entered for multiple days at the same time).
What I would ideally like to have is an entry form that initially has 2 dropdown boxes, one to select the month/year and the other to select the unit.
Once selected I would like to auto populate a table that has the entire months dates in column 1, and then all of the possible emissions for that unit in the next 2:N columns. Then I would like to query the existing database to populate any data that has already been entered for the date/unit combination.
At this point need to let the users input new data, either for just one day or for numerous days. Then save it to the database.
I have approximately 70 possible emissions and approximately 40 units. I will need to be able to add new units and specify their chemicals as well as add new chemicals to existing units as their duties change. I would also like the ability for multiple users to be entering data simultaneously, which I believe is a hallmark of Access and may not be something I have to "turn on".
I hope that there is a way that Access can help me do this and not necessitate using Excel (which is very clunky in this case).
Thanks in advance,
Ben
The format for the data can simply be:
Date Unit Chemical1 Chemical2 Chemical3
1/1/16 UnitA 0 0.1 0
1/1/16 UnitB 0 0.3 0.2
1/1/16 UnitC 0.2 0 0.5
I'll need to do more analysis of the data, but given it as shown would be more than sufficient for the remainder of the work.
For the data entry from I would like to have two drop down boxes: (1) Month/Year and (2) Unit Name. And then the form that the users would fill in would list each day of the month in the left-most column and then give all of the chems that unit could emit in the following columns.
So if:
Unit1 was able to emit ChemA and ChemC
Unit2 was able to emit ChemB
Unit3 was able to emit ChemA, ChemB, and ChemC
So the entry form for Jan-2016 for Unit1 would give them the following assuming today is the 3rd and they have entered data for the 1 and 2.
(1)Jan-2016 (2)UnitA
Date ChemA ChemC
1/1 0.1 0.2
1/2 0.2 0.1
1/3
Then selecting unit 2 would change the available columns and again show the last 2 days entries and allow for the entry of today
(1)Jan-2016 (2)Unit2
Date ChemB
1/1 0.1
1/2 0.2
1/3
Finally Unit3 has all 3 chemicals available and would show the previous data and the blank entries.
(1)Jan-2016 (2)UnitB
Date ChemA ChemB ChemC
1/1 0.1 0.1 0.1
1/2 0.2 0.2 0.2
1/3
I don't mind (and would prefer) that all of the dates for a month were populated and not just the next date. So that January would have 31 rows, Feb would have 29 (this year), etc, etc.
01-21-2016
Wayne, my current tables are:
UnitList
ID UnitName UnitOwner UnitLocation UnitDesc AllowedChems
The last column AllowedChems, is a multiple selection that is linked to the table ChemicalList which looks like:
ID ChemicalName MassUnit Type
Where all of the entries from ChemicalName are possible selection in the AllowedChems field of UnitList
Then I have a table called Tracking with the columns:
ID EDate UName Vent ThOx
At the end of this list I would like to have a column for each of the chemicals listed in ChemicalList, that way the users can input a number for the mass of that chemical they are emitting and it will be transferred to the correct column. But I'm as yet unable to determine if I'm able to build columns by linking them to the contents of another table. Perhaps there is another way around this?
For example if my chemicals are listed in the ChemicalList table as:
ID ChemName
1 ChemA
2 ChemB
3 ChemC
Then I want the Tracking table to look like:
ID EDate UName Vent ThOx ChemA ChemB ChemC
And grow each time a new chemical is added.

Related

libreoffice calc lookup: return value if date is between two dates

I have a list (csv) of payments (and their timestamps) from certain phone numbers and a separate list (also csv) of subscriptions, plus start and end dates of the subscriptions for said phone numbers.
However, several phone numbers have had 2 subscriptions historically (ie. started one, stopped it, started a new one) and I need to associate each payment with the right subscription.
Essentially, I need a way to do
"FOR
this payment RETURN the subscription.id WHERE subscription.phonenumber=payment.phonenumber AND payment.timestamp IS BETWEEN sub.startdate AND sub.enddate".
How can I accomplish this with a formula? For those that only had a single subscription, I just did INDEX MATCH, however I can't see that working here
Let's say you put 2018-01-01 to A1 and 2018-12-31 to A2. Then the date to be tested (e.g. 2018-06-01) to A3. Put =IF(AND(A3>A$1;A3<A$2);"True";"False") to e.g. B3, this will give True. If you put 2019-06-01 to A3, it'll give you False.

Mysql datatype for money

i was trying to create a money related app in which users can choose their currency. Mysql datatype i tried is decimal(19,4). Now the problem is few currencies need three precisions and some need two
Eg:
oman rial needs three precisions. ie 1000 baisa = 1 omani rial. Hence my customers may enter 6.783 omani rial.
Where as my US customers will need only 2 precisions as 100 cents = 1 dollar and they may enter 5.50.
When i insert these two entries to my database using decimal(19,4), it is saved as 6.7830 and 5.5000 respectively.
Now the real pain is when i need to display their entrys as i dont want to display that extra 0 in omani rial entry and that 00 in US dollar. I also tried float but last digit gets rounded off at times.
Is there any mysql data type in which i can save exact entry as it is without any rounding off or extra zeros? If there is no such entry, how can i make it ppssible?
You can use VARCHAR to store exact representations, but I don't recommend that because it takes more bytes to store a number as a string. And any arithmetic you do on the value will convert it to a number anyway.
I recommend you use DECIMAL(19,4), and then format the value in application code, to display it with the appropriate digits. Every programming language has some function like printf() that allows you to control the output formatting, regardless of the value stored.

Excel changes time-format to datetime with MSQuery

I make with Excel a MSQuery to obtain some fields from a table in MySql what is working fine but there is one column which has in MySQL a time-format and Excel delievers me this in datetime-format.
I can format the cell in Excel so that it shows me the time in format hh:mm that is not the problem but I had to use these fields from the database to do some calculations in Excel which leads to my problem: I can't make a sum over these fields when the sum is greater then 24 hours, because then I get only the value of the hours and not from the days multiplied with 24 (e.g. instead of 25:15 I get only 1:15).
Normally I use for this format [hh]:mm so there will be displayed all values (even for more then 24 hours) but this doesn't work here, because I get a very high value (for example: 1017144:15). The reason for this is, that Excel adds for every field to the time the acrtual date of today (e.g. 12:00 will be 12.01.2016 12:00) and with this for every time in the sum the value for the date will be add additionally.
I tried it with the following statement in the MSQuery:
SELECT
DATE_FORMAT(entry.timeBegin, '%h:%i') AS 'Beginn',
entry.timeEnd AS 'Ende',
TIME(entry.pause) AS 'Pause'
FROM timetable.entry entry<br>
All 3 columns have in the database in MySQL the format hh:mm. Ende and Pause behaves like described above and Beginn is formatted in the right way (just without formatting the field by Excel) but the content of the field has type string and with this, Excel always use 0 (zero) for these fields when calculating with them, so I get allways 0 as sum.
I know that I can build the sum in MySQL, but this is no solution for me because the user could set some filters in Excel and this is to complicated to build in the query, espacially this is only one part of a more difficult construct.
Ok, here are a few examples. 'Beginn' allways delivers 0:00 (as described above) and 'Ende' and also 'Pause' are allways equal together. So we have to consider Ende or Pause with hh:mm and [hh]:mm format:
0:00 leads to 0:00 / 1017144:00
1:30 leads to 1:30 / 1017145:30
20:00 + 3:00 leads to 23:00 / 2034311:00
21:30 + 3:00 leads to 0:30 / 2034312:30
I didn't try PowerQuery because I don't know it till now and I don't know if it is inside of Excel or MS. I don't want to install an additional tool on the PC for every user. If I had only to take it into my Excel-sheet so it could be a solution if it is functions right.
Supplement: I looked after PowerQuery and see that this will bring me problems, because the most users uses MS Office 2010 and the requirement with Excel 2010 is Microsoft Office 2010 Professional Plus mit Software Assurance and the feature Software Assurance is not present in our company.
Added: For more clearness I add a screenshot from Excel:screenshot of Excel
I get column A from SQL displayed in format h:mm.
Column B is the same just in number-format.
D2 and E2 are the Sum from A1:A10 in format h:mm respectively [h]:mm:ss.
D3 and E3 are the Sum from A1:A23 in format h:mm respectively [h]:mm:ss.
As you can see SQL delievers the Time 5:30:00 via MSQuery and Excel shows me 14.01.2016 05:30:00 which I can format in the right way (column A). Building the sum is possible (look D2) as long as it is smaller than 24 hours else I get only the hours (< 24) which are greater than a entire day. The reason for this you can see in D3 and E3.
What can I do to get the right values? I suppose the easiest way would be at the point of getting the data from MSQuery.

Showing a calculation of % of Referrals from from MD's in access

I have a table that is based on data entered into a form for new patients to our clinic. One of the parts of the form is a check box that shows if a patient will need one or multiple disciples (Speech, Physcial, Occupational, Feeding Therapies) to our staff and is stored in the tables as 0 and -1.
I would like a simple way to show how many we have for each discipline unsing a subform or query that I can then refrence and then calculate it as a %
Example:
ST: 550 55%
OT: 200 20%
PT: 100 10%
FT 150 15%
Total: 1000
We just recently switched from a Google Sheet for all this data to Access. I was able to do a very very easy and simple PivotTable with Sheets, but the pivot tables in Access make me want to throw things.
Welcome to MS Access. you can achieve this by using count function:
SELECT Count([Speech])*100/Count([patient_id]) AS TotalSpeech,
Count([Physical])*100/Count([patient_id]) AS TotalPhysical,
Count([Occupational])*100/Count([patient_id]) AS TotalOccupational,
Count([Feeding ])*100/Count([patient_id]) AS TotalFeeding
FROM tbl_patient;
of course you need to change the column names as per your table. the calculation is count(therapyType) * 100 divide by total patient = % of TherapyType used by patients.

Using running totals in MS access report cumulatively

I am developing a db (MS access 2010) to support a school with a well-defined model for tuition quotation. The list of products is assembled for each quote, then various discounts are applied. The discounts may be a percentage or an absolute dollar amount. So far, so easy. The problem is that their business logic requires:
No limit on number of discounts.
Specific discounts to be applied in a defined sequence (implemented in my case with a "discount ordinal" column, values 1 (first applied) to 100 (last applied).
Each sequential application of a discount is to the running total of the quote. Eg: Total products $1000. Discount: 50%. Value: $500. Subtotal $500.
Subtotal: $500. Discount: $25. Value: $25. Subtotal: $475.
Subtotal: $475. Discount: $10%. Value: $47.50. Subtotal: $427.50.
This appears to be a variation of the "get the value of the field in the previous row" problem, but with the added twist that the "value of the field" is actually a cumulative calculation. It has the flavor of recursion: while discounts remain, subtotal(previous subtotal).
I have no clear idea how to implement this in a report, because the calculation as noted above is self-referential. I'm not looking for code here, just guidance on the general approach to the problem (ie, some kind of global variable, using VBA - in which case, I'm not sure what the "glue" between the query in VBA and the report would be - or some trick with a calculated field although I've spent a lot of time trying to figure one out). Any thoughts?
In that kind of situations, I always create a new table, that will get filled up when the report opens, and base the report in that table, not the original one. That way I can do all the calculations I need, even making several passes. The report then is simply a "dump" of the table. Complex totals can be additional columns, that will be shown only in the totals section.
You could have table for purchase history using an integer to link each purchase since an autonumber by itself will not link each discount stage.
So in excel I would use something like this:
v = Starting Value
i = 1
Do Until i = Last Discount
d = ws.Cells(i, 9).Value
v = v * (1 - d)
ws.Range("B2").Value = v
i = i + 1
Loop
At each stage you could write to the table (using docmd.runsql) the discount applied (d) and the value (v) but it could be quite slow. You could then order the table by purchase identifier then descending by value since sequential discounts will inherently order correctly.