There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers error excel external hard drive firefox format freezes freezing hard drive hardware hijackthis install internet internet explorer itunes keyboard laptop malware motherboard mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan usb virus vista vista 32-bit windows windows xp winxp wireless
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Connecting Access and VB 6 application


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. Enjoy!

Closed Thread
 
Thread Tools
Tshimega's Avatar
Junior Member with 13 posts.
 
Join Date: Aug 2004
Experience: Beginner
08-Sep-2004, 08:26 AM #1
Connecting Access and VB 6 application
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
Helen Eyob's Avatar
Junior Member with 11 posts.
 
Join Date: Jul 2004
Experience: Beginner
10-Sep-2004, 03:45 PM #2
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.
Helen Eyob's Avatar
Junior Member with 11 posts.
 
Join Date: Jul 2004
Experience: Beginner
10-Sep-2004, 03:45 PM #3
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.
Tshimega's Avatar
Junior Member with 13 posts.
 
Join Date: Aug 2004
Experience: Beginner
10-Sep-2004, 05:07 PM #4
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
Helen Eyob's Avatar
Junior Member with 11 posts.
 
Join Date: Jul 2004
Experience: Beginner
10-Sep-2004, 05:38 PM #5
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....
coderitr's Avatar
Distinguished Member with 3,080 posts.
 
Join Date: Oct 2003
10-Sep-2004, 08:34 PM #6
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.)
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:04 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.