Jump to content

Recommended Posts

Posted

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?

Posted
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

Posted

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 ;))

Posted
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

Posted

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.

Posted (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 by SYNACK
Posted
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.

Posted (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 by powdarrmonkey

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...