-
Sorry about this question. I am very new to using Access 97 with VB, anyways here is the question.
I have an Access 97 database. it has one table in called books. in the table there is 4 fields with only about 5 rows of data. Here is an example. the first field in this simple database is called book names, under that i have 5 book titles. I want to be able to read the very first book title in that field. ( i guess this would be called a record set, im not sure) I just want to see the code to read the first field and just that one row.
Thanks for any info on this
-
<?>
Code:
'mdb name is Books, table is Books, Field is Books
'connection is DAO, dataControl = data1
'data1,text1,command1
Private Sub Command1_Click()
'open the mdb (I store all files in appPath
Dim AppPath As String
If Right(App.Path, 1) <> "\" Then _
AppPath = App.Path & "\" _
Else AppPath = App.Path
cDBName = AppPath & "Books.mdb"
cTblName = "Books"
Data1.DatabaseName = cDBName
Data1.RecordSource = cTblName
'select what you want in the recordset...I've selected all
Dim sql
sql = "Select * from books"
'set the data control to the recordsource (sql)
Data1.RecordSource = sql
Data1.Refresh
'go to first record and display it in text1
Data1.Recordset.MoveFirst
Text1.Text = Data1.Recordset!books
End Sub