Connecting to a database

  • Thread starter Thread starter Robert
  • Start date Start date
R

Robert

Hello,

i am trying to create a program in vb6.0 that links with a
database in access 97.

my target is to create a form that will search through
records within the database (there are 3 tables linked)
and then display this data in 3 different ways on a new
form, these ways are:
single record,
multiple record,
and parent/child

can anyone please help me with coding?
i could also do with a hand telling me how i should
approach this program.

Thank you,

Robert
 
Robert, Visual Basic (VB) is fundamentally different to Access. So VB forms
are not the same as Access forms. A person could be the world's best expert
in Access forms, & have no clue about VB forms. You really need to get a VB
book, or ask your question in a VB forum.

And, your database is not an "Access" database! Access is just a "front end"
program to the actual database management program, MS Jet. VB can also act
as a front-end to MS Jet. Your database is a Jet database, not an Access
one. Access would not be involved in your application at all, methinks!

HTH,
TC
 
Here is some sample code that uses a function that returns information from a Access97 Database

You have to set a reference to MIcrosoft DAO 3.51 Object Librar

Public DBMDatabase As Strin
Public DBMTable As Strin
Public row As Intege
Public strTheRecord As Strin

Private Sub Form_Load(
DBMDatabase = "C:/db1" ' replace C:/db1 with the full path of your data bas
DBMTable = "Table1" 'Replace table1 with the name of your table
row = 1 ' this is the row number from which the data will be returne
strTheRecord = ReadRecord(DBMDatabase, DBMTable, row
Label1 = strTheRecor
End Su

Public Function ReadRecord(DBMDatabase As String, DBMTable As String, row As Integer
Dim XDatabase As Database 'declar
Dim XRecord As Recordse
Set XDatabase = OpenDatabase(DBMDatabase & ".mdb") 'open d
Set XRecord = XDatabase.OpenRecordset(DBMTable, dbOpenDynaset) 'open recor

Dim z As Intege
Dim x As Boolea
z =

x = Fals
With XRecor
.MoveFirs
R =
Do Until R = ro
.MoveNex
R = R +
Loo
.Edi
DBMRecordstr = !Field1 ' replace Field1 with the name of your fiel
.Updat
End Wit

XRecord.Clos
XDatabase.Clos

ReadRecord = DBMRecordst
End Functio

Good Luc
Tom
 
Back
Top