Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Posts
    23

    Unanswered: How to populate table using unbound form

    I have a table: customer. I have a form called frmCustomer with eight fields that is used to enter data into table Customer. I want to be able to enter data into the field and click enter. Having read the forum discussions and researched other resource, still noting is working. I tried the scrpt below nothing happened. Not sure if I am doing something wrong. can you help me. I am using Access 2003


    Private Sub Command9_Click()

    Dim db As Database
    Dim s As Recordset
    Dim tmpUser As String

    Set db = CurrentDB
    Set rs = db.OpenRecordset("select * FROM Customer" & _
    "WHERE CustomerID = ' " & Me.CustomerID & "'")
    Me.SiteNo = rs!SiteNo
    Me.LicenseNo = rs!LicenseNo
    Me.CFirst = rs!CFirst
    Me.CLast = rs!CLast
    Me.Address = rs!Address
    Me.City = rs!City
    Me.Zip = rs!Zip
    Me.Phone = rs!Phone

    rs.Close

    Set rs = Nothing
    Set db = Nothing

    End Sub
    Last edited by osimini; 08-14-08 at 05:31.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by osimini
    strSQL = "INSERT INTO Customer SiteNo, LicenseNo, CFirst, CLast, Address, City,Zip, Phone)" & _
    You're missing an open bracket.
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Looks like the original post was heavily edited after yours george...

    Now there is no space between Customer and WHERE.

    Also, this code is [trying to] load info from the table and populate the form fields, not populate the table from the form as the title suggests.

    Perhaps that is the problem?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Talk about heavy editing, very little of that code is the same! Pfft, trying to make me look stoopid

    To the OP - try a .MoveFirst on the recordset.
    George
    Home | Blog

Posting Permissions

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