473,394 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

need urgent help

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
Jan 18 '07 #1
1 1595
Killer42
8,435 Expert 8TB
Expand|Select|Wrap|Line Numbers
  1. Command1_Click()
  2. Dim con As New ADODB.Connection
  3. Dim con_string As String
  4. Dim sql As String
  5. Dim rs As New ADODB.Recordset
  6. con_string = ''Provider = Microsoft.Jet.OLEDB.3.51; Data Source = '' & App.Path & '' \ '' & ''timesheet.mdb; ''
  7. con.Open con_string
  8. 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
  9.     hoursworked = hoursworked + rs(5)
  10.   End If
  11.   rs.Movenext
  12. Wend
  13. Text3.Text = hoursworked
  14.  
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
You have not created a recordset "rs". You have opened a connection to the database ("con.Open con_string"), but then you didn't do anything with it. You need to open a table, query or whatever, and assign the result to rs.
Jan 19 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jenny | last post by:
Need urgent help for an unsolved problem. In our ASP web application, we creat a Back button and if user click on this button, it execute history.go(-1) to go back to the previous page. All our...
3
by: Rahul S. | last post by:
Hey all: I need urgent information how to set the environment in Visual.NET wiritng in C. I am working with a licensed version of the Analyze 6.0 software from mayo clinic. I need to write...
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
2
by: Max Power | last post by:
Hi All I am coding a small app in that swaps specific files between a client and server. All files and locations are set at both sides. I want my app to show a file list, based on the file...
1
by: TexCube | last post by:
Hello everyone, I have an urgent question. Can data be pulled from an access database table to create a directory that can be printed out and bound together? I need to have each row of a...
10
by: David Thielen | last post by:
Hi; I have help html pages for each page of my ASP.NET webapp. So for the page datasource.aspx, I have help\datasource.htm. Bu what I want when the hyperlink is clicked, for it to look for the...
0
by: sanjayhire | last post by:
Hi All, I have just joined the forum. I need your help..As it's very urgent... How to identify a particular process is running on a server(Windows/Unix server) using VB program and since how...
1
by: psantosh12 | last post by:
Hello Frnds Please need help to resolve error.......... it is very very urgent........ The error is Runtime Error Description: An application error occurred on the server. The current custom...
5
by: Justin | last post by:
Here's my XML: <?xml version="1.0" ?> <AppMode Type="Network"> <CurrentFolder Path="c:\tabs"> <Tabs> <FilePath>tabs\Justin.tab</FilePath> <FilePath>tabs\Julie.tab</FilePath> *****There could...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.