Results 1 to 8 of 8

Thread: object variable ......Not set error

  1. #1

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901

    object variable ......Not set error

    I don know whats going on.. I kinda figured i cannot do this..
    but it looks alright..

    What am i doing wrong?



    VB Code:
    1. Private dbsBlastRoom As Database
    2.  
    3. Private rstDustCollector As Recordset 'DustCollector
    4. Private rstFan As Recordset 'DCFans
    5. Private rstHp As Recordset 'DCMotor
    6.  
    7.  
    8. Private Function CalcPurchParts(dec As tDustCollector)
    9. 'ALREADY SET dB VAR
    10. CalcPurchParts = Recordset("DCFans", rstFan, mDustCollector.Description.m_FanSize)(2) + _
    11.                         Recordset("DCMotor", rstHp, mDustCollector.Description.m_FanHp)(2) 'ERROR ON THIS LINE
    12.                        
    13. End Function
    14.  
    15.  
    16.  
    17.  
    18.  
    19. Private Function Recordset(Table As String, rstVariable As Recordset, itemSeek As Long) As Recordset
    20. Set rstVariable = dbsBlastRoom.OpenRecordset(Table)
    21.     rstVariable.MoveFirst
    22.     rstVariable.Index = "PrimaryKey"
    23.     rstVariable.Seek "=", itemSeek
    24. rstVariable.Close
    25. End Function

    Thanks
    Seahag
    ====================

  2. #2
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    The function Recordset doesn't return anything

  3. #3
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Well, you did not create the instances for your recordsets.

    Private rstDustCollector As Recordset 'DustCollector
    Private rstFan As Recordset 'DCFans
    Private rstHp As Recordset 'DCMotor

    Shouldn't this be

    Private rstDustCollector As new Recordset 'DustCollector
    Private rstFan As new Recordset 'DCFans
    Private rstHp As new Recordset 'DCMotor

  4. #4

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Originally posted by axion_sa
    The function Recordset doesn't return anything
    Ok.. i have revised .....

    VB Code:
    1. Private Function Recordset(Table As String, rstVariable As Recordset, itemSeek As Long) As Recordset
    2. Set rstVariable = dbsBlastRoom.OpenRecordset(Table)
    3.     rstVariable.MoveFirst
    4.     rstVariable.Index = "PrimaryKey"
    5.     rstVariable.Seek "=", itemSeek
    6.     Recordset = rstVariable
    7.    
    8. rstVariable.Close
    9. End Function

    But now its a invalid use of property??




    As well... techyspecy.. i cant do that because i get.. Invalid use of New Keyword


    Seahag

  5. #5
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    you are using DAO 3.6?

  6. #6

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Originally posted by kleinma
    you are using DAO 3.6?


    yes

  7. #7
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724
    Originally posted by SeaHag
    Ok.. i have revised .....

    VB Code:
    1. Private Function Recordset(Table As String, rstVariable As Recordset, itemSeek As Long) As Recordset
    2. Set rstVariable = dbsBlastRoom.OpenRecordset(Table)
    3.     rstVariable.MoveFirst
    4.     rstVariable.Index = "PrimaryKey"
    5.     rstVariable.Seek "=", itemSeek
    6.     Set Recordset = rstVariable ' *** Must use the Set keyword
    7.    
    8. rstVariable.Close ' *** This will close the return aswell.
    9. End Function

  8. #8

    Thread Starter
    Fanatic Member SeaHag's Avatar
    Join Date
    Jul 2001
    Location
    Lake Huron
    Posts
    901
    Thank you..

    What started out as saving some code... ended up turning in to
    variable all over the place.. Argg...

    Whats an efficient way of automating a
    recordset connection ?

    Seahag

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width