In the interest of full disclosure, I must admit that this is the first time I have ever tried using Access, let alone worked with VB. I came up with an idea for an access database that will help me keep track of allowed and used vacation/personal time much easier and with fewer errors than doing it manually, as I have been.
I am trying to switch from a text box that pulls from a table created by a query to one that automatically calculates the information needed. Pulling from the query created table is not ideal due to possible status changes changing the way PTO is calculated. If someone changes from FT to PT (or vice versa), I need their allowed vacation amount to update automatically, rather than having to rerun the query to get it figured out.
This is what I have so far. Yes, I know the syntax I'm using is probably incorrect, but this was done using the nested IIf statements as a guide. And my VB book won't be here until sometime near the end of next week. (Yes, I am one of those who will purchase a manual just to complete one project)
Biggest problem at this point is I don't want PTOyear to have to be in a table somewhere - I'd like to just declare it at some point that PTOyear = 2010 (or 2011 next year, and so on...) - If Status.Employees="FT" Then
-
If PTOyear-Year(HireDate.Employees)>=20 Then
-
AlwdVac.Form1="160"
-
Else
-
If PTOyear-Year(HireDate.Employees)>=16 Then
-
AlwdVac.Form1=(PTOyear-Year(HireDate.Employees))*8
-
Else
-
IF PTOyear-Year(HireDate.Employees)>=5 Then
-
AlwdVac.Form1="120"
-
Else
-
IF PTOyear-Year(HireDate.Employees)>=2 Then
-
AlwdVac.Form1="80"
-
Else
-
If PTOyear-Year(HireDate.Employees)=1 Then
-
If 12-Month(HireDate.Employees)>2 Then
-
AlwdVac.Form1="64"
-
Else
-
AlwdVac.Form1="40"
-
Else
-
If 12-Month(HireDate.Employees)>2 Then
-
AlwdVac.Form1=ROUND((12-Month(HireDate.Employees))*2.67,0)
-
Else
-
AlwdVac.Form1="0"
-
Else
-
If Status.Employees="PT" Then
-
If PTOyear-Year(HireDate.Employees)>=20 Then
-
AlwdVac.Form1="100"
-
Else
-
If PTOyear-Year(HireDate.Employees)>=16 Then
-
AlwdVac.Form1=(PTOyear-Year(HireDate.Employees))*5
-
Else
-
IF PTOyear-Year(HireDate.Employees)>=5 Then
-
AlwdVac.Form1="75"
-
Else
-
IF PTOyear-Year(HireDate.Employees)>=2 Then
-
AlwdVac.Form1="50"
-
Else
-
If PTOyear-Year(HireDate.Employees)=1 Then
-
If 12-Month(HireDate.Employees)>2 Then
-
AlwdVac.Form1="40"
-
Else
-
AlwdVac.Form1="25"
-
Else
-
If 12-Month(HireDate.Employees)>2 Then
-
AlwdVac.Form1=ROUND((12-Month(HireDate.Employees))*1.67,0)
-
Else
-
AlwdVac.Form1="0"
-
Else
-
If Status.Employees="ARR" Then
-
AlwdVac.Form1="0"
-
Else
-
If Status.Employees="SAL" THen
-
AlwdVac.Form1=""
-
'This needs to be able to be entered manually, as the allowed vacation and personal for Salaried employees can vary
-
Else
-
AlwdVac.Form1="Status Needed"
Thanks in advance for any constructive help you can give me!
5 1674
dear,
Where are the "END IF" of the nested IF's?
Please, is it possible to write the code in stadges, it will be much better to understand for us.
like :
============
If .... then
if ... then
...
else
if... then
...
else
...
end if
end if
else
....
....
end if
=============== ======
br,
dear,
sorry but quick replay delete the leading spaces.
I resend the structure: - If .... then
-
if ... then
-
...
-
else
-
if... then
-
...
-
else
-
...
-
end if
-
end if
-
else
-
....
-
....
-
end if
br,
dear,
I think i see a struckture and it will be better to use the "select case" instead of all these "if then else"s.
Is it like this? -
Select Case Status.Employees
-
Case "FT"
-
Select Case PTOyear - Year(HireDate.Employees)
-
Case Is >= 20
-
AlwdVac.Form1 = "160"
-
Case Is >= 16
-
AlwdVac.Form1 = (PTOyear - Year(HireDate.Employees)) * 8
-
Case Is >= 5
-
AlwdVac.Form1 = "120"
-
Case Is >= 2
-
AlwdVac.Form1 = "80"
-
Case 1
-
Select Case 12 - Month(HireDate.Employees)
-
Case Is > 2
-
AlwdVac.Form1 = "64"
-
'§ here i'm losing track: 2x "AlwdVac.Form1 =" ????
-
'§ 2x "If 12 - Month(HireDate.Employees) > 2 Then" ?????
-
End Select
-
End Select
-
Case "PT"
-
Select Case PTOyear - Year(HireDate.Employees)
-
Case Is >= 20
-
AlwdVac.Form1 = "100"
-
Case Is >= 16
-
AlwdVac.Form1 = (PTOyear - Year(HireDate.Employees)) * 5
-
Case Is >= 5
-
AlwdVac.Form1 = "75"
-
Case Is >= 2
-
AlwdVac.Form1 = "50"
-
Case 1
-
Select Case 12 - Month(HireDate.Employees)
-
Case Is > 2
-
AlwdVac.Form1 = "64"
-
'§ here i'm losing track: 2x "AlwdVac.Form1 =" ????
-
'§ 2x "If 12 - Month(HireDate.Employees) > 2 Then" ?????
-
End Select
-
End Select
-
Case "ARR"
-
AlwdVac.Form1 = "0"
-
Case "SAL"
-
AlwdVac.Form1 = ""
-
'........
-
br,
I understand where and why you got lost. But if I understand your procedure correctly, the code for calculating personal time would be: - Select Case Status.Employees
-
Case "FT"
-
AlwdPers.Form1="16"
-
Case "PT"
-
AlwdPers.Form1="10"
-
Case "ARR"
-
AlwdPers.Form1="0"
-
Case "SAL"
-
AlwdPers.Form1=""
And completing what you started (ignoring PT since it's basically the same as FT) would be: - Select Case Status.Employees
-
Case "FT"
-
Select Case PTOyear - Year(HireDate.Employees)
-
Case Is >= 20
-
AlwdVac.Form1 = "160"
-
Case Is >= 16
-
AlwdVac.Form1 = (PTOyear - Year(HireDate.Employees)) * 8
-
Case Is >= 5
-
AlwdVac.Form1 = "120"
-
Case Is >= 2
-
AlwdVac.Form1 = "80"
-
Case Is = 1
-
Select Case 12 - Month(HireDate.Employees)
-
Case Is > 2
-
AlwdVac.Form1 = "64"
-
Case Is <=2
-
AlwdVac.Form1= "40"
-
End Select
-
Case Is = 0
-
Select Case 12 - Month(HireDate.Employees)
-
Case Is > 2
-
AlwdVac.Form1 = ROUND((12-Month(HireDate.Employees))*2.67,0)
-
Case Is <= 2
-
AlwdVac.Form1 = "0"
-
End Select
-
End Select
Which brings up two questions for me...
Do I have to "End Select" the original "Select Case Status.Employee s"?
And how do I declare in there that PTOyear = 2010?
Thanks so much for your help!!
Dear,
Yes, Your structure seems to be working.
Q1 - Yes, a "Select Case" must always be closed with "End Select" like the "If" must always be closed with "End If".
The structure of "Select Case" is : - Select Case ...
-
Case x
-
...
-
Case y
-
...
-
Else Case (if previous cases are not valid and there must be done something)
-
End select
Q2 - There are 2 possibilities:
1- if PTOyear = 2010 must not change during the use of the program, set it in the code => PTOyear = 2010.
In this case, if it must change over the years, you must change it in the program and so compile it each time !!!.
I think it's better to set it on the form with a TextBox. (see option 2)
2- if the user must change it set it with a Textbox on the form.
Set it in the program with (if the Textbox name = Text_PTOYear):
PTOyear = Val(Text_PTOYea r.Text)
br,
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Anand |
last post by:
Hi i am having trouble adding a recordset into the access database,
the code seems to be working fine it passs and parses through all
variables just fine without showing any errors and also when i access
the recordset it displays the results, what the real issue is that the
entry is not made into the database even though i use the Update
command and i have also tried the BeginTrans and CommitTrans nothign
seems to work and i am unable to...
|
by: Jozef |
last post by:
Hello,
I am trying to put together a module and open a workspace on a database that
has a simple password (using Access XP). This is the lin that I'm having
trouble with;
Set wrk = CreateWorkspace("TestWrkspc", "Admin", conDbPwd)
conDBPwd is a variable that contains the password. There is no independant
workgroup file, just the default. This is the error message I'm getting;
|
by: Jozef |
last post by:
Hello,
I'm having trouble with the download links on my web server. The error I'm
getting is;
CGI Timeout
The specified CGI application exceeded the allowed time for processing. The
server has deleted the process.
It's a fresh Windows 2000 server install, but I also installed the ASP.net
|
by: Jozef |
last post by:
Hello.
I'm having trouble creating a blank solution (and ASP.net web application)
from my laptop. I own the server (in fact it's sitting right next to me)
and have added the URL to the trusted sites on my laptop. Here are the
details;
This is what I'm selecting from the start page....
>Add New Blank Solution
>Visual Basic Projects,
|
by: MLH |
last post by:
Am having trouble with the filter property setting below.
Would like to filter the listing to car makes beginning
with "D". I'm blowing it on the filter spec somehow???
Sub OpenRecordsetX()
Dim MyDB As Database
Dim rstTemp As Recordset
Dim rstTemp2 As Recordset
Set MyDB = CurrentDb()
| |
by: Michael |
last post by:
Hi all,
I'm having trouble PInvoking a TCHAR within a struct.
I'll paste the specific struct's API definition below.
I've tried so many numerous variations.
The main Win32 error I get is 0x3f0 / 515L which amounts to ERROR_NO_TOKEN.
Every single instance of this in the past was due to mistakes I made while
within PInvoked structs.
Is anybody able to point me to documentation or just tell me outright how to
|
by: Stu |
last post by:
Hi guys,
I've been having trouble getting the clock function to work portably,
please could I get some thoughts?
<Possibly OT comments>
It works fine on my laptop (under WinXP) and on my office computer
(under Linux), but I have to write some code for the system simulator
for the Cell BE processor (the thing inside the PS3), which is
apparently a PPC architecture, and I can't get the clock function to
|
by: jaesik |
last post by:
Hi all,
I've been working on my personal portfolio website and been struggling a lot because of J-query. Since my j-query level is not like master.. I usually modify existing j-query plugins to meet my needs and this time I'm trying to combine both accordion plugin and slideshow plugin.
I used the tutorial for accordion from this website -
http://acrisdesign.com/2010/03/jquery-tutorial-toggle-effect-on-hoverclick
also used the...
|
by: Connor Bergman |
last post by:
Im trying to create a bank statement basically, and Im having trouble formatting the output to a grid, from a .txt file. And I wrote the file, and can read the first line, and want to pull the date out, and seperate the amount. And with the following lines say the date, type of transaction, the location, amount of the transaction, and finally the running total.
here is what I'm looking to achieve with this:(with all the numbers and columns...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |