1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Connecting Access and VB 6 application

Discussion in 'Software Development' started by Tshimega, Sep 8, 2004.

Thread Status:
Not open for further replies.
Advertisement
  1. Tshimega

    Tshimega Thread Starter

    Joined:
    Aug 18, 2004
    Messages:
    13
    Hi,

    I have a form in VB 6 called frmEMPLOYEE with 3 textboxes namely: First_Name, Last_Name and Employee_Id . I also have a table in access called tblEMPLOYEE. How to I create a button to take whatever that I have on the text boxes and puts in into the database.

    I have tried:


    Private Sub Command1_Click()

    Dim Rs As Recordset

    'Set Rs = CurrentDb.OpenRecordset("tblEmployee", dbOpenTable)

    Rs.AddNew

    Rs("Employee_Id").Value = Text3
    Rs("First_Name").Value = Text1
    Rs("Last_Name").Value = Text2

    Rs.Update
    End Sub

    But this doen't help. Again how do I link the application with the database. I am using access 2000 and VB 6

    Thanks
     
  2. Helen Eyob

    Helen Eyob

    Joined:
    Jul 26, 2004
    Messages:
    11
    You don't need a command button to update your table. Make sure the record source for your form is your table and for each text box, the control source is the field name (coulmn name) for each.
     
  3. Helen Eyob

    Helen Eyob

    Joined:
    Jul 26, 2004
    Messages:
    11
    You don't need a command button to update your table. Make sure the record source for your form is your table and for each text box, the control source is the field name (coulmn name) for each.
     
  4. Tshimega

    Tshimega Thread Starter

    Joined:
    Aug 18, 2004
    Messages:
    13
    Thanks...another problem

    I have created a table in access and on one of the fields in Employer table, I have stored a picture in the column "IMAGE" as an OLE object. Now I have created a form in VB 6 and I have linked all other fields successfull and they do appear on the form. On the same form I want to also to display the picture relating to the same employee that is in the database in the VB 6 form. When I try linking the Image box to the recordsourde, say "adoEmployee" and then I choose the datafield as "Image", running the form displays a message "Unable to bind field or DataMember: IMAGE"....please help....

    Beginner
     
  5. Helen Eyob

    Helen Eyob

    Joined:
    Jul 26, 2004
    Messages:
    11
    Open a data access page in Design view.

    In the toolbox, click the Image tool (drag your mouse over it so you'd know which one it's. It looks like a couple of hills with the sun on top :)).


    Click Field List (it looks like a document) on the toolbar to display the field list.


    From the field list, drag the field that contains a path to an image to the data access page (I think you named this column Image, so just drag that to your form where you want the pic to be displayed). Place the upper-left corner of the icon where you want the upper-left corner of the image to be, and release the mouse button.

    That's it....
     
  6. coderitr

    coderitr

    Joined:
    Oct 12, 2003
    Messages:
    3,015
    The problem with the code you post is as follows:

    Code:
    Rs("First_Name").Value = Text1
    should be ...

    Code:
    Rs.Fields("First_Name").Value = Text1.Text
    Note that I dislike depending on default properties. For one thing, VB.Net doesn't support them so at some point you're going to have to change this code to comply with that if you plan on it being around that long.

    Alternatively, you can also reference the database columns without the invoking the .Fields collection like this

    Code:
    Rs!First_Name = Text1.Text
    Data binding is a good idea and it has its place but it's not always the answer. It surely makes it easier to update existing data by just changing it on the screen and letting the database provider do the work for you. Like I said though, it's not the answer for everything. (In my humble opinion.)
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Connecting Access application
  1. leachim
    Replies:
    0
    Views:
    574
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/271568

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice