Access VBA - After Update Event - ms-access

Need Assistance in generating a specific value to display on a form using vba on a Microsoft Access Form depending on how many combo boxes have a name.
For example if the User selects, 'Tom' the project will cost 10, if Tom and Jerry are selected then 20, if Tom Jerry and George then 30. So I want 'some other field' to populate a fixed amount based on how many of these combo boxes have values.
Please assist and thank you!
X = 10 * (7 - (Abs(IsNull(Me!txtTestDirector.Value)) + Abs(IsNull(Me!txtSystemOperator.Value)) + Abs(IsNull(Me!txtTestEngineer1.Value)) + Abs(IsNull(Me!txtTestEngineer2.Value)) + Abs(IsNull(Me!txtAnalyst.Value)) + Abs(IsNull(Me!txtTrainee1.Value)) + Abs(IsNull(Me!txtTrainee2.Value)))

Try with:
Value = 10 * (TotalCoboboxCount - (Abs(IsNull(Me!Combobox1.Value)) + Abs(IsNull(Me!Combobox2.Value)) + ... + Abs(IsNull(Me!ComboboxN.Value))))

Related

Code combination in microsoft access (yyxxxx format)

I'm struggeling with a part of code that I want to implement in Microsoft Access.
The required code is used for project asignments.
The code format contains the last 2 numbers of the year + 4 digits which add up until a new year, then the last 2 numbers of the year add up with 1 and the 4 digits start at 1 again.
For example:
2019:
190001 = first task;
190002 = second task;
etc...
2020:
200001 = first task;
200002 = second task;
etc...
Could anybody help me out how to code this in Microsoft Access, preferably by VBA?
This way I can asign the code to a "submit" button to avoid similar numbers.
Thanks!
Formatting your code given an integer could be achieved in several ways, here is one possible method:
Function ProjectCode(ByVal n As Long) As Long
ProjectCode = CLng(Format(Date, "yy") & Format(n, "0000"))
End Function
?ProjectCode(1)
200001
?ProjectCode(2)
200002
?ProjectCode(100)
200100
You probably need to assign the next task id to a project.
So, look up the latest id in use and add 1 to obtain the next task id:
NextTaskId = (Year(Date()) \ 100) * 10000 + Nz(DMax("TaskId", "ProjectTable", "TaskId \ 10000 = Year(Date()) \ 100"), 0) Mod 10000 + 1
Nz ensures that a task id also can be assigned the very first task of a year.

Percentage Calculation In SSRS

when i am calculating like given below in SSRS 2008
=SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0))/((SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0))+ SUM(IIF(Fields!REMARKS.Value = "BAD",1,0))))*100
getting result like 34.9632565235
but i am trying to get result like 34.97%
Please share your expertise.
Thanks
Try:
=FORMAT(
SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0))/
((SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0)) +
SUM(IIF(Fields!REMARKS.Value = "BAD",1,0)))),"P2")
Or you can use a custom string format:
=FORMAT(
SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0)) /
((SUM(IIF(Fields!REMARKS.Value = "GOOD",1,0)) +
SUM(IIF(Fields!REMARKS.Value = "BAD",1,0)))*100)
,"0.00") & "%"
Let me know if this helps.
You can also use the Round function in your expression. With this function =ROUND(..., 1) you will have one number after the decimal point. If you want two numbers after the decimal point then enter 2, and so on. (So you need 2).
Also check the link : Percentage SSRS
Where the example is used :
=Round(((SUM(Fields!FirstCallResolution.Value) / COUNT(Fields!CommunicationId.Value)) * 100),1)

Sum values in ssrs with excluding one field

I have a report and need to Sum values from Input_Type (they are Actuals, Adjustment, Estimate, Forecast and Budget, but I need to exclude Budget).
If I use this condition, I get an error.
=SUM(IIF(Fields!INPUT_TYPE.Value = "Actuals" + Fields!INPUT_TYPE.Value = "Adjustment" + Fields!INPUT_TYPE.Value = "Estimate" + Fields!INPUT_TYPE.Value = "Forecast",Fields!VALUE.Value, 0), "GlobalReport")
Could you please help me?
Try the reverse of what you're attempting to write.
=SUM(IIF(Fields!INPUT_TYPE.Value = "Budget", 0, Fields!VALUE.Value), "GlobalReport")

To handle the increment and decrement of a value in an expression and display the corresponding indicator SSRS reporting service

I have a table table of values displayed in SSRS .
The table has fields metricID , currentmonth , preciousMonth
Questions :-
1. I have to compare 2 values like current month and previous month
Fields.PreviousMonth.Value < Fields.CurrentMonth.Value
THEn Check if the metric id is metricID is 7 then increase in currentmonth should be displayed as up arrow with red colour else it should be downarrow with green colour.
For all other Metric ID's it should be "upp arrow with green colour" else "down arrow with red colour"
Does anybody have an idea on how to do this
To do this you will need to set up custom indicators and set an appropriate expression to set the indicator.
I have some simple data:
And a simple report with an indicator per row:
The indicator is set up as:
Where the expression is:
=Switch(Fields!MetricID.Value = 7 and Fields!CurrentMonth.Value - Fields!PreviousMonth.Value > 0, 1
, Fields!MetricID.Value = 7, 2
, Fields!MetricID.Value <> 7 and Fields!CurrentMonth.Value - Fields!PreviousMonth.Value > 0, 3
, true, 4)
So what I'm doing is assigning each row a specified state based on your business rules, and I've set appropriate icons for each of those states.
Report is working as required:
You could move the expression above into a calculated field in the Dataset if you needed to use it in multiple places in the report.

get specific value from parameter

I have a multi-valued parameter TimeMonthOfYear(from cube) that contains January Februrary...December.
I want to set a default value showing current month using MonthName(Month(Today)) (I tried it and it didn't work) when running report...
If I do this [Time].[Month Of Year].&[October] it works! October is selected in dropdown after previous dropdown (Year) was selected.
I don't want to do it the "hard coded" way...I have tried
[Time].[Month Of Year].&[MonthName(Month(Today))] and
="[Time].[Month Of Year].&["&MonthName(Month(Today))&"]" without luck
Any help is very much appreciated!
Yup :) Well it's now working with may be a not so nice solution but will work for now with the help of vb code. in standard value I have ="[Time].[Month Of Year].&[" + Code.SetMonth() + "]" and custom code Function SetMonth() As String Dim x as STRING x =CStr(MonthName(Month(Today))) 'CStr not needed I think If x = "januari" Then x = "January" ElseIf x = "februari" Then x = "February" ... End If Return(x) End Function That is giving me the current month after selecting value in year drop-down :)