Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Linking VB To A Database.

I have a vb interface that has four labels: NAME, AGE, NATIONALITY, and AMOUNT.each label has an adjacent textbox .Two command buttons at the bottom.

ihave difficulties of linking this program to Microsoft Access so that my data can be stored.
Would someone please give me the steps?

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Database Linking In VB6
I am doing a project where I have a logon screen, and the values are then compared to a database with all usernames and passwords, but I am having some trouble understanding how to access the table in the database after I type in the password. How should I do this? The search will be triggered by a submit button, and the text from the UserID and the Password text boxes should then be compared to the database data in the table. How do I do this?... Thanks in advance! I need help!

Linking DataBase
Hi All......

Have 2 forms and 1 Database with 20 text box
Form1 has 10 text boxes and the database object (data1)
Form2 has the rest 10 text boxes taking data from the (data1)


Now when I load data from the database the two forms pages works and you see the fields in the form 1 and form 2.

If I try to load another record ONLY form 1 Data changes, Form 2 Still holding the same old Record (The first one loaded at start Up)

What I want is form 2 should change its data WHEN I load any record from (Data1)

When I put the 20 text boxes on one form every thing works fine, split them into two forms, form 1 works form2 don’t!

Please Help.

Linking A Database To VB

I am trying to link an Access 2000 database to a form in VB 6.0. However, when I try to set the RecordSource propery of the data control, I receive this error - "Unrecognized database format"? Any suggestions on how to fix this?


Linking Vb To A Database
Ive set up a database that is linked to VB, the database is holding stock levels, in VB when i click on a button, i want to it remove one item from the database.


in the database there is 100 bottles of Bud, when i click a button i want it to remove one, so my database should now hold 99 bottles of bud.

anyone know the code to help me do this please??

Linking To Database
i'm a newbie to vb.presently i'm working on a project.i'm dont know how tolink the data base like oracle to my be more precise,i'm working on a hospital management project and i gotta link all the names of patients doctors(entire database) etc to my project.someone please help me out....

waiting to hear from someone

Linking To Database
i have a problem when i try to run my VB program to a MS Access database. i will be prompted with an error say "Unrecognised Database Format". can anyone who knows kindly reply to me ASAP.
Thank You

Linking To A Database
I know it is possible but have forgot!! How can I link an Access or Excel database to VB6 pro?

I would appreciate a reply


Help: Vb And Database Linking
Hey i was wondering if someone can help me with this: Whats the correct syntax for writting and accessing data to and from a microsoft access 2003 database? thanks alot.

Linking To Database
I'm designing an Quote System that links to an Access Database which has 4 tables, Customers, Quotes, Quotedetails, SalesRep.

Quotes contains the following fields:

Quote# - links to Quotedetails([Quote#], [Item],[Qty], [Price])
RepCode - links to SalesRep([RepCode], [RepName], [email])
Cust - links to Customer([code],[Name],[Address] ..etc)

Customers and SalesRep are not to be edited, simply their codes stored when a new quote is created.

The quote may contain a number of lines in Quotedetails.
I need to be able to Add, Delete, Find etc ... )all basic simple functions) with both quotes and quotedetails.

All tutorials I find only link to a database with 1/2 tables and I cannot find any to help me out.

Can someone please post an attachment or a good tutorials website or something to show me how its done? I know this is pathetically simple but we all gotta learn sometime.

Thanks a mill.

// this is how I'm linking to the database
Dim connStr As String
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:QuoteSystemQuote.mdb;Persist Security Info=False"

adoSalesRep.ConnectionString = connStr
adoSalesRep.RecordSource = "Select * From SalesRep"

adoQuoteDets.ConnectionString = connStr
adoQuoteDets.RecordSource = "Select * From QuoteDetails"

adoQuoteNo.ConnectionString = connStr
adoQuoteNo.RecordSource = "Select * From Quote"

adoCust.ConnectionString = connStr
adoCust.RecordSource = "Select * From CompanyDetails"

Set cboQuoteNo.DataSource = adoQuoteNo
cboQuoteNo.DataField = "QuoteNo"

Set cboRep.DataSource = adoSalesRep
cboRep.DataField = "RepName"

Set cboCust.DataSource = adoCust
cboCust.DataField = "CompName"

Set dtgQuoteDets.DataSource = adoQuoteDets

Linking A Database
I wasnt to display the contents of a database in a datagrid control. Any ideas?

Linking A Database. Help!
I am trying to link a MS Access database to a VB6 project but an error pops up about the file being in the wrong format. I know that it is a really easy task for you experts but I am stumped! (Could a step by step guide be provided?!?)


Hi All......

Have 2 forms and 1 Database with 20 text box
Form1 has 10 text boxes and the database object (data1)
Form2 has the rest 10 text boxes taking data from the (data1)


Now when I load data from the database the two forms pages works and you see the fields in the form 1 and form 2.

If I try to load another record ONLY form 1 Data changes, Form 2 Still holding the same old Record (The first one loaded at start Up)

What I want is form 2 should change its data WHEN I load any record from (Data1)

When I put the 20 text boxes on one form every thing works fine, split them into two forms, form 1 works form2 don’t!


Please Help.

Database Linking - Need Help Please.
Hi guys been a while since ive needed help but god this has me stumped.

I have a peice of software that uses a database, it uses the .db format for the database.

Now I'm writing software that utilizes the features in that database that sadly the software company didnt set up correctly and it doesnt work.

So what im trying to do is link my software to the .db file, im confident with .mdb but not sure what engine to use, as i would normally use the jet for .mdb but not used .db before hehe.

Once i get this info on how to link it, im down the road of shared locking hehe (pulls hair out)

Big Al.

Any help would be appreciated.

Note: if i change the .db to .mdb format with rename, i can access the database and see all teh fields using microsoft access, thats how i managed to get the idea for this software.

Just an update on me:

Horse Predictor v0.99 Beta is coming out early next year! Have a few things to do to make it copyrighted but those who helped me here with a few features will be thanked in the readme.

Linking 2 Tables From 2 Different Database?
Hi, I have a problem here, I have two access database, 1 uses DAO (access 97) and the other uses ADO (access 2000), is there anyway which I can link the two tables from these two database? I need the information from one to the other.

Linking To A Database With A Label Box
i wanna know how to display all records of a certain database field inside a text or label box.. how do i do this..

Linking VB App. To Unix Database
I have run into a problem that I wish to experiment with at my office. Our main client database is unix and we have developed an application for our QA staff in VB. Has any one every linked a Vb app. to a Unix data base? How was it done ??? help! help! help!

Linking A MS Database Problem
Hay guys. Got a problem with linking a Access DB. I always get the same error and cannot see what is wrong with it! Any ideas?

Dim MyWorkspace As Workspace, MyDatabase As Database
Dim MyTable As Recordset
Dim MyFile As String

Private Sub Form_Load()

UpdateDb = True

' Define name of database.
MyFile = App.Path & "MP3Database.mdb"
MsgBox MyFile
' Open database.
Set MyWorkspace = Workspaces(0)
Set MyDatabase = MyWorkspace.OpenDatabase(MyFile)
' Open table.
Set MyTable = MyDatabase.OpenRecordset("TrackInfo")
' Move to first record.
'Display first records on form.
Filename1.Text = MyTable!Filename
Artist1.Text = MyTable!Artist
Titledb.Text = MyTable!Title
Album1.Text = MyTable!Album
Albumcoverpath.Text = MyTable!Albumcoverpath

End Sub
Its this bit of code where I get the error:

Set MyTable = MyDatabase.OpenRecordset("TrackInfo")
I get a 'Run-Time error 13: TYpe mis-match' error and cannot see what is wrong? ANy ideas? THanks guys!

Linking VB To Access Database
Hi guys..

I'm new to using Access but I've been using VB for a while. I'd like to know how to link my VB program to access dbase. Is there a good tutorial/link to learn more about this..something that can get me going??


Using A Datagrid Without Linking It To A Database?
I'm making an order form, and I have two datagrids; one is linked to a MySQL database, and one is not. The first is a grid showing all of the products in the database. The second grid will be the items for this current order. When a product is doubleclicked in datagrid one, it will appear in datagrid 2. How can I manually set the number of columns (and titles of these columns) of the datagrid, and insert information into it without connecting it to a database?


Linking A Database To Excel Vba

Using excel I’m trying to link a database to a ‘Adodc’ then show the data base on a ‘Datagrid’ I managing to link the database to the ‘Adodc’ thru ‘connection string’ & ‘record source’ this seems to be working fine.

My problem is that I cant get the database to show on the datagrid.

Ive have done it before using VB6.0. On the properties section of the datagrid was a box to select ‘data source’ this doesn’t seem to be on the VBA version in excel.

So how do you do it?

Thanks for your help.


I've tried the office development section but no one has been able to help.

Linking Access Database To VB6.0
Hi All ,

I want to link the data from Access database to my VB.I understand that if we made any changes to our database,our VB will also have the updated changes and vice versa. But i've tried both ways(changes to VB and changes to my database) but they don't seem to be linking.My source codes is as followed:

Set rdAccessconn = New ADODB.Connection '*** connect to db
With rdAccessconn
On Error GoTo ErrorHandler
.ConnectionString = "dsn=phonebook"
.CursorLocation = adUseClient
End With

Set rsRetrieve = New ADODB.Recordset '***retrieve data from database
strRetrieve = "SELECT * FROM Phonebook"
rsRetrieve.Open strRetrieve, rdAccessconn, adOpenStatic, adLockReadOnly

This Portion : Display data to VB/made changes(Not in source codes)

Set rsPgridAdd = New ADODB.Recordset '***store changes to database
rsPgridAdd.Open "delete * from Phonebook", rdAccessconn, adOpenStatic, adLockOptimistic
rsPgridAdd.Open "Phonebook", rdAccessconn, adOpenStatic, adLockOptimistic

Anyone please help.Thanks lot in advance.

Database Linking Problem
Hello all.

I am working on a VB project that involves connection to MS database and I am encountering a few problems.

One of them being with the add function that I put into. Whenever I add in 2 or more new set of record, it will display me this error:

I've created several table for the database and some of them are linked by relationships.

The debugging thingy will highlight my adodc1.recordset.addnew, and the adodc1.recordset.update if I clicked the update button. It works fine previously though..

I've searched the forums but couldn't find any answer. Anyone care to help?

Database Linking And Updating

I'm new to VB6 and please forgive me for asking this question. I have this data entry process with the following info:

1. I have 2 tables GroupDetail and GroupMaster with field GrpNo as the link to GroupMaster;

2. During a customize data entry screen, i have to update GroupDetail field "GrpName" from GroupMaster table field "grp_name", which I have no idea yet on how to fetch that field value during Addnew.

Part of the code I'm thinking is as follows:

With Data1.Recordset
!GrpNo = Left(cbo_grpno, 2)
!GrpName = value should be from GroupMaster table field "grp_name"
End With

Would appreciate if you can share some info on this.


Access Database Linking
I've written a small program which looks at an access database from my website. I have an Ado data control which looks at a certain table in the Access 2000 db and shows:
(Text box A) Member number
(Text box B) The recipient's member number
(List box C) Their message to another member

Another table in the db links the same member number to the respective member's name.

What I want to do is have 3 text boxes, "Member name A" , "Member name B" and "Message" but currently I have numbers instead of names. As I increment the Ado control I want the member name to change relative to the member number.

Do I need another Ado control in there or can I do it another way?

Linking VB 6 To Access Database

I'm using Visal Basic 6 and want to link it to a table I have created in Access 2003 but I have no idea how to do this. Any help with this would be appreciated.


Help Needed With Database Linking To VB
Basically, I am having difficulty linking my Database to one of my Datacontrols in Visual Basic, When i go the RecordSource Button in the properties what comes up is Unrecognised Database Format, I just dnt understand what the problem is. . .I am working on my project and it has worked b4 but this time it will just not work! If anyone can help me, pls pls pls It is really important and all help will b greatly appreciated! And if anybody could point me in a good direction for any other good VB sites that would b fantastic! Thanx alot...PEACE

Database Table Linking And ADO
Dear Forum EMembers,

Greetings. I wish to ask a question on ADO. If I open a recordset whose datasource comes from a SQL which join 2 tables below:

Course (CourseID; CourseName)

SubCourse (CourseID; SubCourseID; Price)

Course <------------ SubCouse

SQL Join:
SQL = "SELECT Course.*, SubCourse.SubCourseID, SubCourse.Price FROM Course, SubCourse WHERE Course.CourseID=SubCourse.ID"

rsCourse.Open SQL, con, adOpenStatic, adLockOptimistic

Then if I use rsCourse.AddNew, then will this can set CourseID to the SubCourse table too? Will this work? Or should I separately use two recordsets to achieve the purpose? What's your usual practice of ADO for treating two tables? Please give me some advice on which method is better. Thank you

A Problem With Linking A Database
i'm currently working on a project with VB6 which involve linking database.
the problem is that the program dosen't recognize any database either Access or DBase, and it produces an error 3343.
so i was wondring if anyone could help me out on what to do

thanks all

Linking To An Access Database
could any body tell me whats wrong with ths code as i am stumped.any help would be great

Private Sub Form_Load()
Dim dbMyDatabase As Database
Set dbMyDatabase = OpenDatabase("MyDatabase.mdb")
Dim rsMyRS As Recordset

Set rsMyRS = dbMyDatabase.OpenRecordSet("MyTable", dbOpenDynaset)

End Sub

Private Sub lstRecord_Click()

Dim dbMyDB As Database
Dim rsMyRS As Recordset

Private Sub Form_Load()

Set dbMyDB = OpenDatabase("MyDatabase.mdb")
Set rsMyRS = dbMyDB.OpenRecordSet("MyTable", dbOpenDynaset)

If Not rsMyRS.EOF Then rsMyRS.MoveFirst
Do While Not rsMyRS.EOF
    lstRecords.AddItem rsMyRS!Name
    lstRecords.ItemData(lstRecords.NewIndex) = rsMyRS!ID

End Sub

Private Sub lstRecords_Click()

rsMyRS.FindFirst "ID=" & Str(lstRecords.ItemData(lstRecords.ListIndex))
txtPhone.Text = rsMyRS!Phone

End Sub

Linking A MS-Access Database From FTP TO APP Please Help
 Gday Guys

I have a MS Access data Base That i want to put onto the net and when the App Call it. It calls it from the FTP ATM its calling it from the C:

Code:strCNString = "Data Source=" & VB6.GetPath & "db1.mdb" <---- Make that a Http://WWW.FTP.COM
CN.Provider = "Microsoft Jet 4.0 OLE DB Provider"
CN.ConnectionString = strCNString
CN.Properties("Jet OLEDBatabase Password").Value = "james0304"


VB6 Linking To Database (access)
Hi again

Can anyone point me in the right direction for a tutorial or supply me with instructions for:

I have a form (yipee!) and on that form I need a Combo Box which has a range of names in it, which it gets these names from an access database.

Also on the form, I have several text boxes. One is called txtAddress, another is called txtPhone and so on.

How can I pull down the combo box, select a name (eg. Joe Bloggs) and have his Address displayed in txtAddress and have his phone nmumber displayed in txtPhone?


Linking Forms In Database
When I bring up my part form it shows a different customer then what is showing in my customer form. I want both forms to show the same customer at the same time. This is probably an easy task but I can't seem to figure it out today....


Linking A Table From Another Database Using ADO In VB6
I need to link a table from one database to another using ADO in VB6.

Linking A Text To A Database

Here is my problem:

I want to save a large amunt of text from a textbox and then link it to a certain field from a table from my database.How can I do that?The text is up to 1KB in size

Help Linking Database To Form
I need some help linking a database to my form window. To give an idea what I am trying to do, Ill explain.

I work for an office supply company. We have sales associates who call and ask for various skus for various items. I have created the forms for each category that the associate will use. The problem I am currently running into is setting up a database and figuring out the best way to retrieve the information from it.

This would be a typical scenario that the associate would use the form and database:

Associate would click on the PRINTER CARTRIDGES button which would trigger the corresponding form. The associate would then select the manufacturer of the cartridge from a drop down box. The program would then contact the database and retrieve the different models for that particular manufacturer. The associate would then select the corresponding model and then click get information. The form would contact the database again and return the results to the text boxes on the form (i.e. sku, yield, printers it will work with etc...)

I thought about using MS Access but am having trouble understanding how to setup the database so that when the program calls the db that the information will be right where I need it in the db. I also thought about using Excel so that form could call on the specific cell and return the information in that cell to the text box. What would be easier? I would prefer to use Access tho I am not very fluent with either program or programming.

I would really appreciate any and all help with this project. My company has deemed this project miniscule to put a coporate programmer on it so I have taken the initative to learn myself. And seeing how I am up for a raise this month, I would greatly appreciate any help.

I do have the project files zipped to send to you if you need to reference the program to help me figure it out.

Patrick Masters
Staples Direct

Linking Database Tables
Hello, I'm relatively new to database programming. I've created this database with about 15 tables, I want to link one table with the rest with visual basic code OR with MS Access, but the problem with MS Access is that whatever I try doesn't seem to work...

Please Help

F. T. W.

Image Linking (vb &amp; Access Database)
i am in the process of making a small visual basic program for my computing project in college. it'll basically be a way of viewing/editing/searching employmee personal records easily. the data will be stored in a database made in access. i would like to know if it is possible to incorporate an image box into my program which will change to the image corresponding to the appropriate employee personal record stored in the database as you scroll though the records using a data control. is this possible? and if so i would be very grateful if someone could help me.

Linking Combo Box, Database And If Then Statements
Ok, this may be a stupid question but....I am creating a app where i enter customer data linking the access through VB, When you select the product through a combo box it displays the subtotal. If the customer is from one of 7 states then they are subject to one of two tax rates. I can get the subtotal to display fine but I am trying the use an IF THEN referencing the customer data entered in the previous form. If the State entered matches one of the 7 states then a the appropriate tax rate is used and added to the subtotal. I was wondering how i need the reference the state text field that is linked to access for this to work?

Linking Pictures To An Access Database
A simple way to link in pictures to display on a form from a recordset is

Store the pictures in a folder

Store the path to the picture in a field eg

'picture' as records in an Access database

Put a DAO data control on the form, double click on the data control

put an image control on the form, set to the data control

insert the follwing code for the data control (delete the validate bit!)

Private Sub Data1_Reposition()

Image1.Picture = LoadPicture((""))
Image1.Picture = LoadPicture(Data1.Recordset.Fields("Picture"))

End Sub

Where .Fields("Picture")) refers to the name for the picture field
in the database table. Remember to set the data control to the database and table!

Run the program and see your pictures displayed from the database list as you scroll through the recordset. It also works with a search facility for each record!

This is far easier than other methods out there!!

This works set for a DYNASET recordset.

Linking To Access Database After Upgrading
Hi guys,
I have a program here that access Access 97. But after my company upgraded the operating system to Access 2000, i had problems accessing the database using the same source codes. The error msg said that my database format was wrong.

What code can i add to solve this problem?

Pls help... Thanks.

How To Solve This Variable To Database Linking?
I am new here and need help on :

1) I need to check the condition of Variable A either it's &lt; 30 or &gt; 30 but this A should retrieve it's value in a particular table on field1 row4. Anyway how to assign it? or any other suggestion to solve this problem?

I am new to VB, so be a bit specific k? Thanks in advance.

Linking Database To Visual Basic
hi guys, this is my first post of hopefully not too many

i have to link my visual basic project to a database for a booking form project and i can't get it to save from the form into the database. I can make records from my database show up in the form but not save into the database please can someone supply me with some basic code for me to save it please. the button to click when i want to save is cmdsavebooking and the database table is called CustomerData.

the things i want to save into the database are as follows:

txtprice(1) / txtprice(0) (in a control array - either to be saved would be great thanks )

optextension - All three of these are options in same frame. if one is selected
optdiscount - the other wont be. i just need them in access as checkboxes.
optnodiscount - Just discount and extension need to be saved as Yes/No


Thanks in advance, i hope you can save me!


Create Database Linking An Existing One
Hi people!!!!
I have this database called "DBEmp" in MS SQL Server 2000 stored in hard disk unit "D". I had problems with the main hard disk and i had to install OS and SQL Server again. I have no backup from "DBEmp" but the information is still in disk "D". How could i create this new database using the one stored in D Unit?
Thanks in advanced!!!!

Help Linking Between List Box And Access Database
Sorry if this is a stupid question but I am relatively new to visual basic programming (and programming in general for that matter).

In the project I am doing I have a listbox that is populated with the items from a field called "UserName" in a table in a database (I have this part working). This table also has the field "UserIP".

What I want to do is when the a "UserName" is selected in this listbox the "UserIP" for that user is retreived and stored to a variable. But I don't know how todo this.

Thanks for any help?

Help Linking Text Boxes With Database
hi all,my first post!!! im having trouble remembering a very very simple thing....i have an access database with a couple of fields like firstname/lastname/age etc etc...and i want to link those up with text boxes on my form in vb....i have a module that contains all the necessary opening/closing of connections and whatnot....and i know that works..but i cant for the life of me remember how to freaking link the table/form up correctly...i used to use this format:

firstname.text = table!firstname

but it gives me an error object required????

i hope im giving someone enough information to help me

ill post my module and my form, maybe that will help


''Name - Will Sanquilly
''Course - CIS242
''Module - moddatabase
''Project - interfacePrj
''OpenLink - opens the connection between the module and the database
''CloseLink - closes the connection between the module and the database
''LoadData - loads the recordset
''CloseData - closes the recordset

Public DataLink As ADODB.Connection

Public Sub OpenLink()

Set DataLink = New ADODB.Connection

DataLink.ConnectionString = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = " & App.Path & "girls.mdb"

End Sub

Public Sub CloseLink()

Set DataLink = Nothing

End Sub

Public Sub LoadData(tblName As String, girls As ADODB.Recordset)

Set girls = New ADODB.Recordset
girls.Open tblName, DataLink, adOpenDynamic, adLockOptimistic, adCmdTable

End Sub

Public Sub CloseData()

Set girls = Nothing

End Sub

so after all that stuff....i put:

LoadData "test", girls

in my form load for my form (test is the name of the table im using, girls is the name of the database)

please please help! im making a birthday present/joke program for my friend....

Linking The Field In My Form To My Database, Using DAO
i have got all my fields in my forms and i have provided their places in my tables, i have written them as well, e.x. r!(something) = me.something . it is all i have done and written and i dont know what else i need to write, i know it is a basic question, but i want to learn it as all you experts.
thank you.

Linking Tables (a Database Newbie)
I have 2 tables,

'Guages' and 'Guage records'

'Guages' fields include Instrument Number, Instrument Description and date of calibration.

'Guage records' fields include Instrument Number, Calibration due, Calibrated by, Comment and Status.

I have a data control on the first form with is linked to the 'Guages' table which displays a particular record. There is also a command button,

so that when i click it, a second form appears and gives me the corresponding 'guage records' data for the instrument number as seen on the first form.

How can i link the 2 tables so that the guage records data appears in the second form. Would there be a SQL querie? As i am new to databases i am struggling....

Any help would be extremely appreciated

Linking Foxpro Database With Access
Hai friends,

I have one application running in Foxpro 2.0 MSDOS version. It uses a table called emp which is having some 15,000 records in it. Now I have another one application in Visual Basic, which uses MSAccess as backend. Both these software have to use that emp table. I want to link that table in Foxpro with Access. In File menu in Access we have one option – get external data – link. Suggest me as to whether I do with this. Also tell me whether it will give any problem when I link DOS based database with windows based database.
This Foxpro database is in the server and it is a novel netware server which is dos based and it will not support windows. After I link I want to have my Access data base also in the Novel netware server only which is DOS based. Suggest me as to whether this will work out.
Thanx in advance.

Linking Option Button To A Database
Does anyone know how to link a pair of option buttons to a DB field using ADO?

There does not seem to be any data properties.

Copyright © 2005-08, All rights reserved