Results 1 to 2 of 2

Thread: DAO from scratch...

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 1999
    Location
    Pikeville, KY, USA
    Posts
    12

    Post

    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.

  2. #2
    Junior Member
    Join Date
    Jan 1999
    Location
    Seattle WA USA
    Posts
    21

    Post

    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


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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width