Parameter Queries and Data Controls 
Author Message
 Parameter Queries and Data Controls

Hi,

I am trying to build a form that will have an expanding bottom portion
taht will show all of the detail records for a selected record.  When
the user selects the expand button, I expand the form and set up my
querydef and recordset objects.  I then open the recordset and assign it
to the data control.  This works fine.  When the user the selects the
shrink button to show only the main record and leaves this form, I close
the querydef and recordset.  If the user comes back to this form and
selects the expand again, I get error "525 Data Access Error".   Any
ideas.

Here is the code for the expand button.

        cmdAddStudents.Caption = "<<< Students"
        Set studentQd = addDb.QueryDefs("qrygetstudent")
        studentQd.Parameters!corpkeyparm = corpnum
        Set studentRs = studentQd.OpenRecordset(dbOpenDynaset)
        Set dataAddClass.Recordset = studentRs

Here is the shrink Button.
        studentRs.Close
        studentQd.Close
        Set studentRs = Nothing
        Set studentQd = Nothing

Thanks in Advance,




Fri, 20 Nov 1998 03:00:00 GMT  
 Parameter Queries and Data Controls

Yes, do not set StudentRs = Nothing. The reasons are complicated and
involve far too much indepth OLE to explain. But, studentRs and
dataAddClass.Recordset are both pointers to the one recordset object. When
you set StudentRs to nothing this forcibly unloads the recordset object.
When the datacontrol tries to use it's pointer to the recvordset pointer
again you run into trouble as it no longer exists. You might also try
removing the use of studentRs entirely:

studentQd.Parameters!corpkeyparm = corpnum
Set dataAddClass.Recordset =studentQd.OpenRecordset(dbOpenDynaset)

Quote:

> Here is the code for the expand button.

>         cmdAddStudents.Caption = "<<< Students"
>         Set studentQd = addDb.QueryDefs("qrygetstudent")
>         studentQd.Parameters!corpkeyparm = corpnum
>         Set studentRs = studentQd.OpenRecordset(dbOpenDynaset)
>         Set dataAddClass.Recordset = studentRs

> Here is the shrink Button.
>         studentRs.Close
>         studentQd.Close
>         Set studentRs = Nothing
>         Set studentQd = Nothing



Thu, 26 Nov 1998 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VB4: Parameter query&Data Control?

2. HELP with Parameter queries and Data Control

3. Using Parameter Queries and Data Controls

4. Parameter Queries and Data controls

5. Help! Parameter Query via Data Control

6. How to bind Parameter Query to Data Control ?

7. Parameter query and Data control

8. How to bind Parameter Query to Data Control ?

9. parameter query and data control

10. Passing Parameters to stored parameter queries using VB 5's Data Controls

11. Parameter query for Bound Data Control

12. Data Control and Query Parameters Question

 

 
Powered by phpBB® Forum Software