Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 24th, 2007, 06:33 AM
Registered User
 
Join Date: Apr 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Run-Time error 3705

Im trying to generate a report that gets the data from my Database
using DataEnvironment and Datareport.

This is the code I use to open my datareport.

Private Sub mnuCentreListExaminer_Click()
'
DataEnvironment1.Command4 cmbExaminerno.Text '
DataReport4.Show
End Sub


I also used this SQl ststement in my command.

SELECT Exam_Entries.* FROM Exam_Entries WHERE
Exam_Entries.Examiner_No = ?


The datareport shows all relevent data of 1 Examiner,
that Examiner is indicated by the Examiner number from the textbox cmbExaminerno.Text

When I open the Datareport it works.But if I try to open it
again I get this error,
" Operation is not allowed when the object is open "
I have seen some other people on this website with the same problem who have answers,
and I have tried to adapt those answers to suit me but it still doesn't work

CAN ANYONE PLEASE HELP ME
AND THANX IN ADVANCE


 
Old April 24th, 2007, 10:57 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Opening the report opens the object. Then the report closes without closing that object.
You need to add code to the report (or the report opening routine) wherein the object gets closed when it is no longer needed.

I know that is pretty vague, but then, so is what you posted.

The SQL itself is not the issue. Just guessing here, but perhaps something like
Code:
Private Sub mnuCentreListExaminer_Click()
' <——<<< What is this apostrophe here for?
    DataEnvironment1.Command4 cmbExaminerno.Text '<——<<< And this one?
    DataReport4.Show
    DataEnvironment1.Close
End Sub
or
Code:
Private Sub mnuCentreListExaminer_Click()

    If DataEnvironment1.State <> Whatever_the_Const_is_for_Closed Then
        DataEnvironment1.Close
    End If
    DataEnvironment1.Command4 cmbExaminerno.Text
    DataReport4.Show

End Sub
(Probably would be best to keep the unconditional .Close when you are done with the object, [u]and</u> add code to test the object’s state before trying to use it. Though making tests like this slow your code a bit—practically immeasurably—they make your code overcome obstacles effortlessly.)
 
Old April 26th, 2007, 06:52 AM
Registered User
 
Join Date: Apr 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanx for your answer.
I've tried them both and get the same error 'Mathod or Data Member not found'
could you please help me if you can.

 
Old April 26th, 2007, 10:20 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

What do you mean, “I get the same error ‘Method or Data Member not found?’” You had said that your error was “Operation is not allowed when the object is open.”
Perhaps you mean both attempts at access ing the state give you the same error?

OK, so I’m guessing that you are saying the code I offered is giving this error. If it is on the line that contains the reference to .State, then that is not the right property, and you will need to look through the InteliSense list to find the right property showing the object’s state. The reason you need to check is that sometimes closing a closed object generates an error.

If it is on the line with the .Close, then this is not the correct name for that operation, and again, you’ll need to scan the IntelliSense list to see what the proper operation is.
 
Old May 4th, 2007, 08:10 AM
Registered User
 
Join Date: Apr 2007
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanx for your help and your 1 was very close but my mate just showed me what the problem was.
Here was the solution just to let you know:

If DataEnvironment1.rsCommand4.state = Open Then
Dataenvironment1.rsCommand4.Close
End If
DataEnvironment1.Command4 cmbExaminerno.Text
    DataReport4.Show
End Sub

Oh by the way the bits where i used apostrophes was just to make space so the code is easier to read nothing else.

ANYWAY THANKS FOR YOUR HELP






Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
run-time error(s) Chacko C++ Programming 0 March 4th, 2007 02:28 PM
run time error ashishroyk Java GUI 0 October 8th, 2004 01:42 AM
Run Time Error JBond Access VBA 0 May 27th, 2004 09:50 AM
RUN-TIME ERROR compcad Beginning VB 6 2 May 21st, 2004 02:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.