Results 1 to 9 of 9

Thread: Invalid use of NEW keyword

  1. #1

    Thread Starter
    Member JPRoy392's Avatar
    Join Date
    Aug 2000
    Posts
    50

    Question

    Am I missing something or has my brain taken a early holiday?

    Code:
    Dim rstCountry As Recordset
    Set rstCountry = New Recordset
    how can "New Recordset" be bad?
    (Invaild use of new?)

    I need a vacation.
    Jim

    "...head is all empty and I don't care..."

  2. #2
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Try this mate:
    Code:
    Dim rstCountry As New Recordset
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  3. #3

    Thread Starter
    Member JPRoy392's Avatar
    Join Date
    Aug 2000
    Posts
    50
    I tried that too. Didn't work before. I think that I may have some setting wrong or something.
    Jim

    "...head is all empty and I don't care..."

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Recordset is probably public not creatable
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    Member JPRoy392's Avatar
    Join Date
    Aug 2000
    Posts
    50
    nope it's Private
    Code:
    Private Sub FillCountryCombo()
    Dim rstCountry As New Recordset
    'Dim rstCountry As Recordset
    'Set rstCountry = New Recordset
        rstCountry.Open "SELECT DISTINCT Customers.Country FROM Customers ORDER BY Customers.Country", m_conn, adOpenForwardOnly, adLockReadOnly
        cboCountry.Clear
        cboCountry.AddItem ""
        Do Until rstCountry.EOF
            If Not IsNull(rstCountry![Country]) Then cboCountry.AddItem rstCountry![Country]
            rstCountry.MoveNext
        Loop
    
    End Sub
    Still blows up
    Jim

    "...head is all empty and I don't care..."

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hmm, now i don't get it. Are you the designer of Recordset (sounds like database stuff and i don't know much about them). Because a private class wouldn't be available outside it's project..
    Or do you mean the object is private? Sorry for not being a db expert :/ or whatever
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    If you have multiple libraries then you would have to specify what library you're using:
    Code:
    Dim rs As New ADODB.Recordset

  8. #8

    Thread Starter
    Member JPRoy392's Avatar
    Join Date
    Aug 2000
    Posts
    50
    Thank you both for the help. I forgot "ADODB." in front of th word recordset (Thanks Serge). Can you tell me the difference, so I don't do that again (If you have the time)?

    Thank you everyone and happy holidays!
    Jim

    "...head is all empty and I don't care..."

  9. #9
    Lively Member
    Join Date
    Jul 1999
    Location
    Phoenix
    Posts
    87
    I think he means there are multiple libraries referenced in your project that have something defined as a 'Recordset'

    you can see your project references in the program menu, Project | References

    Since they are both loaded, you have to qualify which library the recordset you want to use belongs to.

    Dim rs as new ADODB.recordset explicitly tells VB which definition of recordset to use.

    Your error sounds like VB was trying to use the other definition of recordset which was not an object that can be instantiated via the new operator

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