Modules & VBA :: How To Calculate Most Recurrent Value
May 21, 2015
I have to make a form with multiple sections. Each section has n questions to which corresponds a numerical value from 1 to 4.
Example:
Question 1 value 2
Question 2 value 1
Question 3 value 3
Question 4 value 2
Question 5 value 4
Question 6 value 2
I have to choose the most recourrent number like the Excel MODA function then in this example is 2.But if there are more then one recurrence with the same times i must choose the highest one.
Question 1 value 2
Question 2 value 1
Question 3 value 3
Question 4 value 2
Question 5 value 4
Question 6 value 4
In the example above number 2 and 4 recur the same number of times and i must choose the number 4 because is the higher.
There is not a MODA function in Access, even if Excel, with the second example returns the most recurrent but the lower value 2.
i have a calendar that works like a charm, but i would like to add the possibility to add recurrent events in it. for instance if a user has to perform a task at a choosen time schedule, it is shown in the agenda, like each week or each two weeks or each month. Anybody any idea how i would aproach this problem or has a sollution?
I am building a simple invoicing system so far with 2 tables customer details item details
The items are usually subscriptions which can last 3, 6, 12 or 24 months (but needs to be flexible if more options are offered in the future) and I am currently storing the start date in field 'start'date' and the number of months the subscription lasts in field 'recurrence'.
Every month I need to produce a report which shows the subscriptions due in that calendar month. Eg: subsc A - start 1/1/06 recurrence 3 months subsc B - start 1/1/06 recurrence 6 months
So report for March 06 would should subsc A due report for June 06 would show subsc A & subsc B due
I would be grateful for any pointers in calculating & producing the report.
i would want my form to calculate the age of a contact by using the inputted birthday, is this possible? and as long as the system clock is right, it should update too? or i'm wrong?
I am looking to calculate numbers in query like this if the field name in query is Unit and the second field name is amount and i want that the amount field to calculate the unit field on this criteria..Suppose if total unit is 393 so the calculation should be like this;
First hundred should be calculated with 100.00 X 5.79 = 579.00 Second 200.00 X 8.11 = 1622.00 Third 93.00 X 12.33 = 1146.69
Total should be displayed in the amount field = 3347.69
I have this code for calculating the age from birthdate but i want if there is years no months or days appear
Public Function CalcAge(Birthdate As Date) As String Dim intYears As Integer, intMonths As Integer, intDays As Integer intMonths = DateDiff("m", Birthdate, Date) intDays = DateDiff("d", DateAdd("m", intMonths, Birthdate), Date)
I am trying to get a module set-up that will add a number of workdays (no weekends, no holidays) to a date that is mentioned in a form and put the resulting deadline date in another field on the same form (date or remaining days to deadline would be even better).
Now it gets a little tricky, the module will need to select different amounts of workdays to be added to the date in the form depending on what status is selected (different statusses have different amounts of days).
I'll probably need: List of holidays List of days required per status Start date (to which the days can be added).
Example:
Status = "DQ" which has 2 days to work with. Start date in form = "21/03/2014". Result = 25/03/2014 or preferably "2 days remaining".
I want to select a date range from "Production" table where it agrees to the Dept_ID too. And then calculate the summation of the columns "hours", "produced" & "waste" of that particular range selection.
This is my code:
Code: Option Compare Database Private Sub cmdCal_Click() Dim sql As String Dim rs As Recordset Dim qdef As DAO.QueryDef Dim hours, waste, produced As Integer
[code]....
But it returns nothing, When i remove the errorHandler, it says that no records were found.
What I have is two fields, one is a simple date and the other is slightly more complex as it holds a date but in a different structure (a dated case number).
The case numbers are for example, 150211551223 the date being the first 6 numbers and equaling to 11/02/2015. so the code will need to grab this data, spin it around and convert it.
The formula will then be:
simpledate - convertedcasenumberdate = days between.
(simpledate will always be the latest date of the two).
At the moment I am working a little project at work and am stuck on how to calculate departments due date based on actual order due date.
example:
OrderID: xxxxxx-xx DueDate: 10/8/13
Now let say i have 5 different departments but I want/need to know what should be the due date for each of those departments based on the due date on top.
How to implement a functionality into my access database. The related tables required for this functionality can be found as an attachment.
When the information has been entered into the tables by the user, I would like to calculate the difference between the information for each part within the same table. The main columns for which the difference have to be calculated are: [RefObsInfo->RefSources] and [AltObsInfo->StatusAltSource] and [GenObsInfo->GenSources]. The values for these fields are restricted to 3 or 4 different ones. I also would like to show if the GenEstAvailable columns are changed, but that's for later.
In order to calculate this difference a query has to select for each Part the information related to the last date AND a date which has been specified by the user (with the previous date as max). For this the user is asked to give a from date, which she/he can select from a combobox. This combobox has a standard selected value which is the MaxDate-1, i.e. the previous date. The difference should be calculated from the previous date to the last date. I would prefer to give each (predefined) difference a specific action to show the user the difference in a matter of seconds.
I have two numbers, i need to calculate how much percentage of one is the other. E.g
num_1 = 100 num_2 = 10 percent = 10%
Users enter a dollar amount (retainer) and my code should calculate the percent of the total proposal amount.
Actual Code
Private Sub cmdSubmit_Click() Dim intProposalTotal As Double 'if i use interger i get "overflow" error intProposalTotal = Nz(DLookup("ProposalTotal", "qryPropsalTotalForRetainer", "proposal_id=" & Me.proposal_id), 0)
[Code] .....
billing_retainer_percent is formatted to Percent with 0 decimals. In the actual table Type - Number, Format - Percent, Field Size - Single. What i get is 100% instead of 10%.
I have a form that have textbox that calculate total and then i want to convert numbers to words. Iv got the code with function currencytotext but when i set the code source of another textbox to:
=currencytotext([inv_total])
I have an error. I saw this on internet but i think bcz I am using access 2013 may be the syntax is different a bit.
I am using the code below to evaluate values for each transaction to determine the median:
Function MedianF(pTable As String, pfield As String, pgroup As String) As Single '******************************************* 'Purpose: Return median value from a recordset 'Inputs: ? medianF("Values", "Industry") <enter> 'Output: results are currently incorrect '******************************************* Dim rs As Recordset Dim strSQL As String
[code]....
The code generates median results based on the value but not the correct ones, as I check results in Excel using the Median function. I need to see the median for the transactions within the same industry and I do not know how to do that . Below are some sample transactions including the Industry, Value, mymedian (which the current results based on my code) and the expected median result (which I calculated in Excel based solely on the transactions listed here). Note that mymedian results listed in the 3rd column are determined using the complete data set (over 2000 transactions). I only included a few sample transactions below to show that I am currently getting 2 different median results: 44.62 and 50.82. Also be aware that I do not want to evaluate any zero value transactions, which I believe I am handling in the strSQL line above where I indicate <>0 . I need to see a Median result for each industry and the result should be the same for all transactions within the same industry.
Industry Value mymedian Expected Median Aerospace 18.01 50.82 40.45 Aerospace 53.02 50.82 40.45 Aerospace 109.18 50.82 40.45 Aerospace 61.54 44.62 40.45
[code]....
This is how I am passing the values from the query to the module, passing the value of Period2 if Period 1 = 0, else passing Period1:
I'm trying to create an automated way of making a way to contact our personnel in case phones cannot be used. I have a list of all the address and currently separated by cities. I want to step it up a bit and with the use of google maps create a shortest route map. So one representative from one city will go to each house, another will go to the other cities to another rep, who then goes to each house in their city.
I would need a map for one person to each of the other reps.
And a map for the reps to drive the shortest route yet hitting all targets.
Is this within the scope of Access and Google Maps? I've looked at some of the database made by others on here but none of them show ability to find shortest route.
I've been trying to solve this problem for the past month and at the verge of destroying my PC! I've trawled through numerous web sites but just cant seem to figure this one out.I'm trying to get access to tell me what the next service moth is based on the start date, end date, and the frequency of service.
For example:
Start date: 01/01/2014 End date: 31/12/2015
service frequency: Every 4 months
Using the above information the service months are: 1 - April 2014 2 - August 2014 3 - December 2014 4 - April 2015 5 - August 2015 6 - December 2015
Suppose that you want to make a formula which will calculate time periods based on a given tariff. To be more precise.
Suppose you can "get in" somewhere, entrance is $2. You are free to stay there, without additional charge, for 5 days. Then, for the next 5 days, the charge is $1 per day The next 7 days, the charge is $1.5 per day Thereafter, $3 per day.
In this scenario, we can make a query, we use datediff function to see the number of days between "gate in" and "gate out".
The problem is that the tariff is not very simple and the query gets to big and difficult to control with lot's of "iif" and may be I need to make more than 4 queries and union select and so on.
I tried to find in the docmd if there is any suitable function that I could use.
Basically, I am trying to calculate a integer number difference from two dates (TAT = Due-Date - Result_Date). The number is calculated and excludes weekends and ideally holidays (for that I have a tblHoliday but not sure how to use it). The function below seems to calculate a number but doesn't exclude weekends.
For example, if Due_Date is 9/26/2014 and Result_Date is 9/30/2014, then TAT is calculated to be 5 (should be 2).Since 9/26/2014 is a Friday only Friday and Monday are used in the calculation.
Code:
Option Compare Database Public Function WorkingDays(StartDate As Date, EndDate As Date) As Long Dim intCount As Long intCount = 0
Currently I use a module to calculate DueDate, excluding weekends and holidays. I store all the holiday in a tblHoliday and reference this table in the module. A formula then calculated the DueDate. This works great in an access form, but I now realize that I need that value stored so it appears on the table as well, but do not know how to accomplish this.
I am trying to use dsum to calculate a sum from either a table or query to display on a form and this needs to be for different services within a period so I am using the following:
The Query is called KatiesPeriodTakings The field I want totalled is called Price The date field is AppDate and the 2 controlling dates are the Startdate and EndDate from the Form
I am using the function below to calculate a field that excludes weekends and holidays. The weekends are excluded as it is now, but when I try to add in code to exclude holidays I am getting errors. The code for the holidays is in bold and a couple of the errors are Loop without Do so I remove the Loop then I get a Else without If.
Code: Option Compare Database
Public Function WorkingDays(Due_Date As Date, Result_Date As Date) As Integer '-- Return the number of WorkingDays between Due_Date and Result_Date On Error GoTo err_workingDays