• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

VB6 Access database (1 Viewer)

tekster

Member
Joined
Jan 9, 2003
Messages
72
Gender
Undisclosed
HSC
N/A
I've got a table in an MS Access database that I'd like to display in a ListView format within a form. I'm not too sure where to get started. Can anyone help me out?
 

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
no idea... sorri
just had to say - luv the avatar rofl XD
 

SamD

Member
Joined
Jul 21, 2002
Messages
256
Gender
Male
HSC
N/A
You could use a data control, which simplifies attachment to the Access file but is somewhat restrictive in terms of what you can do. Have a play by mucking around with the properties of this control as it may suit your needs.

Otherwise open the database in code.

You'll need two variables, one for the database and another for the recordset. The recordset variable holds the view of the data retrieved.

For example to get you started:

Dim db as database
Dim rs as recordset


'open the database then a recordset from this database
Set db = OpenDatabase("C:\MyDB.mdb")
Set rs = db.OpenRecordset("SELECT Field1, Field2 FROM Table1;")

You move around in the recordset using:
rs.movefirst
rs.movenext
rs.movelast
etc...

data in the current record is retrieved using for example:
MyVar = rs("Field1").value


you need to make sure you close the database when you've finished using it:
db.close

HTH
Sam
 

Fiona

Member
Joined
Apr 28, 2003
Messages
135
Location
Sydney
Does anyone know of any sample projects that use access databases, that actually work?
 

:: ck ::

Actuarial Boy
Joined
Jan 1, 2003
Messages
2,414
Gender
Male
HSC
2004
there is actually a huge resource of these online
u can search for them
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top