calculate working hours

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • deena22
    New Member
    • Nov 2006
    • 8

    #1

    calculate working hours

    hello,

    i'm using 'Access database' and VB 6.0. My database is named ' timesheet' and it contains a table named 'tabletimesheet '. The table contain the following fields: 'staffname, stafftype, date, projectname, projectcode and hoursworked' . On my VB 6.0 form, i have got a ' list Box' containing the 'type of staff', for example 'engineer, manager or secretary'. I have got another 'list Box' containing the 'name of projects' . Also i have got 2 textboxes into which the user will enter the 'Start date' and in the other textbox, the user will enter the 'End date'. I have been using ADODC to connect my List Box and Text Boxes to the database through the DataSource and DataField, is it good? The system i'm developing should then find the total number of hours worked from the 'start date' to the 'end date' for the item selected in the 'type of staff' List Box and for the item selected in the 'name of project' List Box. For example, if i choose 'engineer' in the first List Box, i choose 'project aaa' in my second List Box, i enter '4/5/06' as 'Start date' and '10/9/06' as 'End Date', then the 'sum of the hours worked' by the 'engineer' on 'project aaa' from '4/5/06' to '10/9/06' should be calculated and be displayed in a textbox. How do i do that? What are the code to set the connection to access the table in the database and to calculate the sum of the hours worked and to display it in a textbox? Where should i place the codes?

    Need your help urgently.

    Can you please send to my private mail an 'address' where your reply will be posted.

    Thanks
  • aaryan
    New Member
    • Nov 2006
    • 82

    #2
    Originally posted by deena22
    hello,

    i'm using 'Access database' and VB 6.0. My database is named ' timesheet' and it contains a table named 'tabletimesheet '. The table contain the following fields: 'staffname, stafftype, date, projectname, projectcode and hoursworked' . On my VB 6.0 form, i have got a ' list Box' containing the 'type of staff', for example 'engineer, manager or secretary'. I have got another 'list Box' containing the 'name of projects' . Also i have got 2 textboxes into which the user will enter the 'Start date' and in the other textbox, the user will enter the 'End date'. I have been using ADODC to connect my List Box and Text Boxes to the database through the DataSource and DataField, is it good? The system i'm developing should then find the total number of hours worked from the 'start date' to the 'end date' for the item selected in the 'type of staff' List Box and for the item selected in the 'name of project' List Box. For example, if i choose 'engineer' in the first List Box, i choose 'project aaa' in my second List Box, i enter '4/5/06' as 'Start date' and '10/9/06' as 'End Date', then the 'sum of the hours worked' by the 'engineer' on 'project aaa' from '4/5/06' to '10/9/06' should be calculated and be displayed in a textbox. How do i do that? What are the code to set the connection to access the table in the database and to calculate the sum of the hours worked and to display it in a textbox? Where should i place the codes?

    Need your help urgently.

    Can you please send to my private mail an 'address' where your reply will be posted.

    Thanks
    hi deena,
    to get the desired result, here is the sample code
    command1_click( )
    While Not rs.EOF
    If rs(1) = lststafftype.Li st(lststafftype .ListIndex) And rs(3) = lstproject.List (lstproject.Lis tIndex) And CDate(rs(2)) >= CDate(txtstartd ate.Text) And CDate(rs(2)) <= CDate(txtendate .Text) Then
    hrsworked = hrsworked + rs(5)
    End If
    rs.MoveNext
    Wend
    txthrsworked.te xt = hrsworked

    hmm.. to connect your database with the front end, there are so many others who have posted the code. check for sashi's too. you will find them.

    Comment

    Working...