Run-time error '424' Object Require 
Author Message
 Run-time error '424' Object Require

I have create a Customer form and several Navigation control button such
First, Next, Previous and so on. The Navigation control are place on the
same form.  During run-time, when I click on the Next command button I get
an error message "run-time error '424', Object Require". Other buttons also
have the same error message.  

Here are the codes for loading the database and a partial code for the
Navigation button.  Can someone provide a solution for me?  Thanks!

Private Sub Form_Load()
    Dim OldDB As Database
    Dim OldWs As Workspace
    Dim newDyn As Recordset

    Set OldWs = DBEngine.Workspaces(0)
    Set OldDB = OldWs.OpenDatabase("C:\SPTS_DATAs.mdb")
    Set newDyn = OldDB.OpenRecordset("Select * from Cust_Info",
dbOpenDynaset)

 End Sub

' Navigation button
Private Sub cmdNext_Click()
    newDyn.MoveNext
End Sub

Private Sub cmdPrev_Click()
    newDyn.MovePrevious
End Sub



Tue, 29 Aug 2000 03:00:00 GMT  
 Run-time error '424' Object Require

Ken,
        If newDyn is declared in the Form_Load event then it is no longer valid in
the cmdNext_Click or other navagation code. The solution is simply to move
the newDyn recordset declaration to the general section of the Form module
to make it available to all form routines. (Form scope) Moving the
Database, and Wordspace declarations might also be a good idea since you
may want to use them else where. Hope this helps.

Oscar Bowyer



Quote:
> I have create a Customer form and several Navigation control button such
> First, Next, Previous and so on. The Navigation control are place on the
> same form.  During run-time, when I click on the Next command button I
get
> an error message "run-time error '424', Object Require". Other buttons
also
> have the same error message.  

> Here are the codes for loading the database and a partial code for the
> Navigation button.  Can someone provide a solution for me?  Thanks!

> Private Sub Form_Load()
>     Dim OldDB As Database
>     Dim OldWs As Workspace
>     Dim newDyn As Recordset

>     Set OldWs = DBEngine.Workspaces(0)
>     Set OldDB = OldWs.OpenDatabase("C:\SPTS_DATAs.mdb")
>     Set newDyn = OldDB.OpenRecordset("Select * from Cust_Info",
> dbOpenDynaset)

>  End Sub

> ' Navigation button
> Private Sub cmdNext_Click()
>     newDyn.MoveNext
> End Sub

> Private Sub cmdPrev_Click()
>     newDyn.MovePrevious
> End Sub



Wed, 30 Aug 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Run-time error '424' Object Required

2. Run-time error '424' Object required

3. Run-time error '424' Object required

4. Run-time error '424': Object required

5. Run-Time error '424': object Required

6. Run-Time error '424': Object Required

7. Run-time error '424': Object reduired

8. Run-time error '424': Object reduired

9. run time error '424' - object required , why ???

10. Run-time error '424'

11. VB Run time error '424'

12. Run-time error '424'

 

 
Powered by phpBB® Forum Software