Query in text box based on combo box list

yanie

Registered User.
Local time
Today, 13:35
Joined
Sep 23, 2009
Messages
10
Hi, can someone help me to solve this problem..
Currently im doing leave database for my office ..everything looks ok till I found this problem.. i created a form, and name the colums inside as a leave_start_date, leave_end_date,leave_total_days,Leave_type.
I listed all leave type in combo box, example:

CR01 =Annual Leave
CR07 =Half Day Leave
MC =Medical Leave

I tried to create an text box value [leave_total_days] as auto calculation. but I having a problem coz each leave type have a different values..Lets say I select CR07,the text box value should appear a 0.5,then when I select CR01,the text box value should run a query that I type inside
leave_total_days = [leave_end_date]-[ leave_start_date] +1..

Can someone help me..pls :confused:
 
Use the AfterUpdate event on the combo box to populate the textbox value. Use DateDiff to calculate the number of days between the start and end dates.

An example using the field names you gave:
Code:
    Select Case Leave_type
    Case Is = "CR07"
        Me.leave_total_days = 0.5
    Case Is = "MC"
        leave_total_days = DateDiff("d", leave_start_date, leave_end_date)
    Case Else
        leave_total_days = DateDiff("d", leave_start_date, leave_end_date)
    End Select
 
hi there..tq for helping me...its really works..;)...tq..tq..tq very much
 

Users who are viewing this thread

Back
Top Bottom