PDA

Click to See Complete Forum and Search --> : DAO from scratch...


rscott
Jun 30th, 1999, 06:37 AM
I know my problem may be extremely basic to some, but I am presenting my problem in hopes of a solution.

After a bit of research I have come across a two line bit of code to access "mdb" databases. My problem arises when I try to show this data in text fields...

I open the database with this bit of code.
--SNIP--
Private Sub Openthemdb()

Set MyDatabase = DBEngine.Workspaces(0).OpenDatabase("database1.mdb")
Set OurDB = MyDatabase.OpenRecordset("Rolodex")
'Now, we bind the controls to the text fields.

Assignthefields

End Sub 'Openthemdb

--SNIP--
After opening it - I am unsure as how to bind certain text fields to this database.
Here is how I went about it, but failed miserably.

--SNIP--
Private Sub Assignthefields()

SFName.DataField = "FirstName"
SLName.DataField = "LastName"
IAreaCode.DataField = "AreaCode"
SPhoneNum.DataField = "Phone"
SAddress.DataField = "Address"
SCity.DataField = "City"
SState.DataField = "State"
IZipCode.DataField = "ZipCode"


End Sub

--SNIP--

I have declared certain variables Public in hopes that this would alleviate my problem. No luck...

--SNIP--

Public SQL As String
Public MyDatabase As Database
Public OurDB As Recordset
--SNIP--

The text fields that I wish to attach to are seen above. I also have manually entered "OurDB" as the DataSource. Any help would be greatly appreciated.

DVint
Jun 30th, 1999, 02:49 PM
When you use DAO you don't bind the controls. That's for when you're working with a data control. That means you have to provide the code that moves data from the controls to the recordset and vise versa. The general syntax is:
Text1 = RS.Field(n) or..
RS.Field(n) = Text1


------------------