473,473 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help me write some simple codes... I am not a programmer

Can someone help me accomplish the following in a MSAccess Report:

1. Check if Me.Discipline = "RN" (within the source query)
2. Then check the Me.YearOfEmployment: (again within the same source
query)
if <2 then Me.BaseRate = BaseRate,
if between 2 and <5 then Me.BaseRate = BaseRate * 1.03
if between 5 and <10 then Me.BaseRate = BaseRate * 1.03 * 1.03
....

Does the following code make sense?

If Me.Discipline = "RN" Then
If Me.YearOfEmployment < 2 Then
Me.BaseRate = Me.BaseRate * 1
ElseIf Me.YearOfEmployment >= 2 < 5 Then
Me.BaseRate = Me.BaseRate * 1.03
ElseIf Me.YearOfEmployment >= 5 < 10 Then
Me.BaseRate = Me.BaseRate * 1.0609
ElseIf Me.YearOfEmployment >= 10 < 15 Then
Me.BaseRate = Me.BaseRate * 1.09
ElseIf Me.YearOfEmployment >= 15 Then
Me.BaseRate = Me.BaseRate * 1.12
Else
Me.BaseRate = Me.BaseRate * 1
End If
End If
3. How do I bring this new defined Me.BaseRate back to the report? I
mean for the above codes, where should I insert it at? (i.e. Private
Sub Report_Open?)

Sincerely,
Perry
Nov 12 '05 #1
1 1596
I believe I can follow your code close enough to help. It appears you're
close to what you need. One thing I want to verify is the YearOfEmployment
is actually "years of employment", in other words, the number of years
someone has worked there, not the year they were hired.

The syntax needs a little adjusting here:
ElseIf Me.YearOfEmployment >= 2 < 5 Then<<

It should read
ElseIf Me.YearOfEmployment >= 2 And Me.YearOfEmployment < 5 Then

Do this for the rest of the statements also. At the end, you have a final
Else which gives a BaseRate of BaseRate*1. If this is going to be the
default, it is ok, but not necessary, to specify this same rate for <2. If
you don't specify it, when <2 didn't meet any of the other criteria it would
fall through to this default and the answer would be the same.

I believe you may find a different command easier to follow than all of the
If statements. Using this other command, your code would look like:

If Me.Discipline = "RN" Then
Select Case Me.YearOfEmployment
Case Is >=15
Me.BaseRate = Me.BaseRate * 1.12
Case 10 To 15
Me.BaseRate = Me.BaseRate * 1.09
Case 5 To 10
Me.BaseRate = Me.BaseRate * 1.0609
Case 2 To 5
Me.BaseRate = Me.BaseRate * 1.03
Case Else
'Since the result will be *1, we don't need to do anything here
End Select
End If

This is reversed from what you have because the Select Case statement will
execute the first True Case it finds. "Case 10 To 15" will be true, even if
the value is 15 (it won't be limited to less than 15); however, since "Case
Is >=15" comes first, the "Case 10 To 15" will never be seen.

Where to put this? It appears that you are referring to the value of a
textbox called BaseRate on the report. Place the code in the Format event
for that section of the report. This could also be done without the VBA
code, but using a calculated textbox. It will be harder to read that way
(for you, not on the report as seen by the user) but will probably be
faster. For this to work properly, the field name and the textbox name need
to be different. So, if the field name is BaseRate, change the textbox name
to txtBaseRate (this would apply for Discipline also) and place the
following in the Control Source of the textbox.

=IIf([Discipline]="RN", IIf([BaseRate]>=15, [BaseRate]*1.12,
IIf([BaseRate]>=10, [BaseRate]*1.09, IIf([BaseRate]>=5, [BaseRate]*1.0609,
IIf([BaseRate]>=2, [BaseRate]*1.03, [BaseRate])))))

This is also relying on the order of the listed items. If >=15 we get
[BaseRate]*1.12; however, if >=15 is false we then go to the next IIf
statement and see if >=10 is true. We don't need to check for 15 again,
because if the value was >=15 we wouldn't have gotten this far. If all else
fails, then just return [BaseRate]. Note that we don't need a False part for
IIf([Discipline] = "RN".... because you haven't listed what you want to do
in that case.

--
Wayne Morgan
Microsoft Access MVP
"PerryC" <pe******@yahoo.com> wrote in message
news:ea**************************@posting.google.c om... Can someone help me accomplish the following in a MSAccess Report:

1. Check if Me.Discipline = "RN" (within the source query)
2. Then check the Me.YearOfEmployment: (again within the same source
query)
if <2 then Me.BaseRate = BaseRate,
if between 2 and <5 then Me.BaseRate = BaseRate * 1.03
if between 5 and <10 then Me.BaseRate = BaseRate * 1.03 * 1.03
....

Does the following code make sense?

If Me.Discipline = "RN" Then
If Me.YearOfEmployment < 2 Then
Me.BaseRate = Me.BaseRate * 1
ElseIf Me.YearOfEmployment >= 2 < 5 Then
Me.BaseRate = Me.BaseRate * 1.03
ElseIf Me.YearOfEmployment >= 5 < 10 Then
Me.BaseRate = Me.BaseRate * 1.0609
ElseIf Me.YearOfEmployment >= 10 < 15 Then
Me.BaseRate = Me.BaseRate * 1.09
ElseIf Me.YearOfEmployment >= 15 Then
Me.BaseRate = Me.BaseRate * 1.12
Else
Me.BaseRate = Me.BaseRate * 1
End If
End If
3. How do I bring this new defined Me.BaseRate back to the report? I
mean for the above codes, where should I insert it at? (i.e. Private
Sub Report_Open?)

Sincerely,
Perry

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Confused User | last post by:
I am working on device that utilizes a Motorola 68HC16 microcontroller. I am using an old unsupported piece of crap Whitesmith's / Intermetrics / Tasking compiler. The embedded compiler business...
2
by: Joshua Tan | last post by:
hey there, I really need some help with this. I have a web application running on Windows 2000 Server , IIS5.0 , .Net Framework 1.1 I have a file.aspx, file.aspx.cs and file.aspx.resx I...
10
by: stylecomputers | last post by:
Hey guys, I am absolutely new to Linux programming, with no w######s programming experience except a small amount of C++ console apps. Reasonably new to Linux, BSD etc, got good sound networking...
83
by: deppy_3 | last post by:
Hi.I am started learning Programm language C before some time.I am trying to make a programm about a very simple "sell shop".This programm hasn't got any compile problem but when i run it i face...
1
by: karizmatrix22 | last post by:
Hi, I need a programmer who can write 3 programs for following questions below.Programs need to be ready before nextweek.thank you. Person who help me these 3 questions will be get paid.. I am...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
5
by: chapeau_melon | last post by:
Hello, I'm basicly not a programmer... I found some C++ codes on the net that almost satisfy me needs, wich is to communicate with an other device that sends data to me, wich I have to receive...
2
by: bupanda | last post by:
I need to write codes in visual basic for check boxes that "Allow the user choose to display or hide the title, the country name, and the name of the programmer. Use check boxes for the display/hide...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.