Hightower Posted April 17, 2009 Posted April 17, 2009 I have an application which is failing, and it appears to be this line of 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: Compile error: Expected Function or variable Any ideas?
powdarrmonkey Posted April 17, 2009 Posted April 17, 2009 MoveFirst is a function, not a variable, so you can't assign things to it.
Hightower Posted April 17, 2009 Author Posted April 17, 2009 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
powdarrmonkey Posted April 17, 2009 Posted April 17, 2009 You need to use OpenRecordset to open the table... [color=#0000ff]Dim[/color] dbMyDB [color=blue]As[/color] Database [color=blue]Dim[/color] rsMyRS [color=blue]As[/color] RecordSet [color=blue]Set[/color] dbMyDB = OpenDatabase("MyDatabase.mdb") [color=blue]Set[/color] 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 )
Hightower Posted April 17, 2009 Author Posted April 17, 2009 You need to use OpenRecordset to open the table... [color=#0000ff]Dim[/color] dbMyDB [color=blue]As[/color] Database [color=blue]Dim[/color] rsMyRS [color=blue]As[/color] RecordSet [color=blue]Set[/color] dbMyDB = OpenDatabase("MyDatabase.mdb") [color=blue]Set[/color] 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 dataObj.RecordSet.Open the first record that matches SQL Thanks
Hightower Posted April 17, 2009 Author Posted April 17, 2009 Just for further info I already have: 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.
SYNACK Posted April 17, 2009 Posted April 17, 2009 (edited) 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. Edited April 17, 2009 by SYNACK
Hightower Posted April 18, 2009 Author Posted April 18, 2009 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.
powdarrmonkey Posted April 18, 2009 Posted April 18, 2009 (edited) VB6 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. Edited April 18, 2009 by powdarrmonkey
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now