Hi
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'. 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 when the user click on the button ''Calculate Hours Worked '' 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.
Also i have inserted the following codes in my button command:
Command1_Click()
Dim con As New ADODB.Connection
Dim con_string As String
Dim sql As String
Dim rs As New ADODB.Recordset
con_string = ''Provider = Microsoft.Jet.OLEDB.3.51; Data Source = '' & App.Path & '' \ '' & ''timesheet.mdb; ''
con.Open con_string
While Not rs.EOF
If rs(1) = List1.List(List1.ListIndex) And rs(3) = List2.List(List2.ListIndex) And CDate(rs(2)) >= CDate(Text1.Text) And CDate(rs(2)) <= CDate(Text2.Text)
Then
hoursworked = hoursworked + rs(5)
End If
rs.Movenext
Wend
Text3.Text = hoursworked
But when i run the program, i get the following error:
Run time error '3704'
Operation is not allowed when the object is closed
When i click on debug, it highlights the following line of codes:
While Not rs.EOF
Please, solve this problem for me.
Thanks