+ Post New Thread
Results 1 to 9 of 9
Coding Thread, VB6 Help in Coding and Web Development; I have an application which is failing, and it appears to be this line of code: Code: dataCustomers.Recordset.MoveFirst = "SELECT ...
  1. #1

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    241

    VB6 Help

    I have an application which is failing, and it appears to be this line of code:

    Code:
    dataCustomers.Recordset.MoveFirst = "SELECT * FROM tbl_customers,tbl_join WHERE tbl_join.isbn = '" & txtBook(0).Text & "' AND tbl_join.membership_number = tbl_customers.membership_number"
    This is error I am getting:

    Code:
    Compile error:
    
    Expected Function or variable
    Any ideas?

  2. #2

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,866
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    MoveFirst is a function, not a variable, so you can't assign things to it.

  3. #3

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    241
    Quote Originally Posted by powdarrmonkey View Post
    MoveFirst is a function, not a variable, so you can't assign things to it.
    So how would I go about opening the first recordset that matches that SQL?

    Still newish to VB6

  4. #4

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,866
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    You need to use OpenRecordset to open the table...
    Code:
    Dim dbMyDB As Database
    Dim rsMyRS As RecordSet
    
    Set dbMyDB = OpenDatabase("MyDatabase.mdb")
    Set rsMyRS = dbMyDB.OpenRecordSet("MyTable", dbOpenDynaset)
    ...and then do some operation, like FindFirst, Filter, MoveNext, etc. Think of a recordset like a row of shelves that you can walk around.

    (I'd also stop using VB6 and use .Net )

  5. #5

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    241
    Quote Originally Posted by powdarrmonkey View Post
    You need to use OpenRecordset to open the table...
    Code:
    Dim dbMyDB As Database
    Dim rsMyRS As RecordSet
    
    Set dbMyDB = OpenDatabase("MyDatabase.mdb")
    Set rsMyRS = dbMyDB.OpenRecordSet("MyTable", dbOpenDynaset)
    ...and then do some operation, like FindFirst, Filter, MoveNext, etc. Think of a recordset like a row of shelves that you can walk around.

    (I'd also stop using VB6 and use .Net )
    I can't stop using it - it's for Uni!

    Also, I've done one that way (as you have shown above), but I also have to do one the other way which is what I'm looking for. The other way as in using a data object to open the database and table.

    It needs to be something like
    Code:
    dataObj.RecordSet.Open the first record that matches SQL
    Thanks

  6. #6

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    241
    Just for further info I already have:
    Code:
    Set rs = db.OpenRecordset("SELECT * FROM tbl_books,tbl_join WHERE tbl_join.membership_number = '" & txtCustomer(0).Text & "' AND tbl_join.isbn = tbl_books.isbn", dbOpenDynaset)
        rs.MoveFirst
    But I also need to be able to demostrate the other way described above.

  7. #7

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    11,240
    Thank Post
    882
    Thanked 2,742 Times in 2,316 Posts
    Blog Entries
    11
    Rep Power
    784
    Quote Originally Posted by Hightower View Post
    I can't stop using it - it's for Uni!
    Off topic but what Uni are you going to and what course is this for? I find it extremely difficult to figure out the relivance of teaching VB6 at a Uni in 2009 in any other course other than the history of computing.
    Last edited by SYNACK; 17th April 2009 at 03:18 PM.

  8. #8

    Hightower's Avatar
    Join Date
    Jun 2008
    Location
    Cloud 9
    Posts
    4,920
    Thank Post
    494
    Thanked 690 Times in 444 Posts
    Rep Power
    241
    Quote Originally Posted by SYNACK View Post
    Off topic but what Uni are you going to and what course is this for? I find it extremely difficult to figure out the relivance of teaching VB6 at a Uni in 2009 in any other course other than the history of computing.
    It's a HNC/HND/Degree 5 year part time course. I know VB6 is dated and shouldn't be used, but the relevance is (according to lecturer) "being taught how to do things the right way".

    Apparantly the skills we learn in this topic can then be transferred to any visual programming style such as VB.net

    I'm happy with it - really enjoying it, and I don't doubt his teaching methods.

  9. #9

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,866
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    Quote Originally Posted by Hightower View Post
    VB6 <snip> is (according to lecturer) "being taught how to do things the right way".

    o_O


    It's true that learning VB6 will give you skills to transfer, but only really within other Basic languages. It's a very poor language gramatically, and it teaches nothing about typing, memory management, objects, etc, etc.... but then, if you're just starting out it's quite a satisfying language provided you go on to learn those skills later, which I hope you will do.
    Last edited by powdarrmonkey; 18th April 2009 at 02:33 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. Adding components in VB6
    By iking in forum How do you do....it?
    Replies: 1
    Last Post: 15th July 2009, 10:37 AM
  2. VB6 Properties
    By Hightower in forum Coding
    Replies: 7
    Last Post: 27th April 2009, 10:54 AM
  3. Vb6 components on CC3
    By iking in forum Network and Classroom Management
    Replies: 2
    Last Post: 26th October 2008, 05:39 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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