How to Set a default value

djwasim

Registered User.
Local time
Today, 10:42
Joined
May 29, 2009
Messages
93
Hello

i am working on a project where i have a table named

"employee info"

in which the fields are

"employeeid" "employeename" , "employeesalary" ,

and also have another table named

"employeesalary"

in which the fields are

"employeeid" that is linked with the "employee info" table. and an other field named "salary"

where i use to enter employee id and the information related that id is automatically generate from the table named

"employeeinfo"

now i am facing problem that i want to set a field named

"employeesalry" as default value of the field named

"salary"

and also that default value can be editable or changeable manually when i want to change in future.

plz tell me solution as soon as possible

thanx in advance
 
If you have an Employee Table and a Salary Table then you don't need Salary in Employee Table if you have EmployeeID in the Salary Table.
Just one "link" between the two tables is all that you should have.

This sounds like the Salary Table will have a historical record of the EmployeeID's salary over the years.

correct? or how does this work??

Your question at the end gets confusing as you say you want Quote..."now i am facing problem that i want to set a field named "employeesalry" as default value of the field named "salary" " UnQuote.

Do you mean you want the value in employeesalary to also be the value in salary ?
Why ?
and which tables are they on?

Refer above, If you have employeeID as a field in SalaryTable then a query can produce this data when ever you want it.

Having it in two places just causes additional stress for you and your system.

Your query will simply use DLookup to get the current value of the employees salary - bit more to discuss on this if you need help.
 
ok i am agree with you. but the problem is that if in future the salary of an employee will be increase then what can i do? how can i change that salary?
if i use to change salary amount in in the table named "employeeinfo" then the past record also will be changed. all calculations at old salary amount will be changed to new one. but i want to do such a work that the old calculations will remain same with the change of new salary value.
 
Look at "DemoDefaultSalaryA2000.mdb" (attachment, zip).
Look at Tables, Forms, Relationships.
Look at frmEmployeeSalary (Default Value properties on "Salary" field).
Look at frmEmployeeInfo VBA.
Open frmEmployeInfo and try.
I think it is what you need.
 

Attachments

Thanx dear

but there is still a problem that if in period there is a number of chances to increase of decrease a salary amount.

anyways leave it.
can you tell me one thing more?

that how can we set a field as a default value of another field

for instance

there are tow fields in a form named

"field A"
"field B"

then if the value of "field A" is 5000 $
then automatically 5000$ will be shown in "filed B"
and if i want to change the amount in "field B" to 4000$ instead of 5000$. then it will be possible to change manually.

i Will be thankful to you
 
A default value takes effect as soon as a new record is inserted and during that point there will be no value for field A. So I'm assuming you mean you WHENEVER the value of Field A changes to 5000$ then FieldB changes to 5000$?
 
If you have a SalaryTable then you will have records of all your Salaries.
You have a field in this Table called employeeID. This means that each record of the SalaryTable has at least DateEffective, EmployeeID, SalaryGross plus a few more.

This will be one to many relationship with the EmployeeTable.

For Employee Jack Jones EmployeeID 1235 you may have 6 records in the SalaryTable.

When you query the data you look for the record with 1235 as the EmployeeID and the "Top" (few ways to do this) so you only get the Latest Salary for Jack.
At any time you can look back in history and see what salaries Jack had over the last few years and what date each Salary was effective.
Another way is to add a field to the SalaryTable called SalaryStatus. The current Salary will have "Current" displayed in this field and all other, for Jack will have "Past"
You now have Effective Date and Status to ensure you are able to select either Current Salary or Past Salary and also show there respective dates.
 

Users who are viewing this thread

Back
Top Bottom