Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > Problems with VB and Access 2002


Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2003, 12:06 PM
Jquiz
Guest
 
Posts: n/a
Question Problems with VB and Access 2002


I have an application that runs with an Access 2002 DB, I want to grab the data from two field inside one table. The database is on a network drive z:\dictation\Data\pathist.mdb. I want to list the data inside a listbox. Is there a problem with VB 6 and access 2002. Granted I am very new to VB but I have followed the steps in 2 different books on connecting to an Access DB and I can not get it do work. Some direction would be wonderful.

I can connect to access 97 DB but I am still unable to get the data to display in a list box.

I get the error:
Unrecognized database format "dir of database"
This happens when I try my database verses the northwind database.

If I use the northwind I can display information in a text box but nothing shows in the list box and when I change the DB I get the above error.

Q

Last edited by Jquiz; 02-13-2003 at 12:16 PM.
Reply With Quote
  #2  
Old 02-13-2003, 01:25 PM
vbNEMESIS's Avatar
vbNEMESIS vbNEMESIS is offline
Junior Contributor
 
Join Date: Jan 2003
Location: PA
Posts: 312
Default

You cannont connect to an access 2000 or later database using dao, which, if you were connecting to a 97 database, is probably what you were using. You need to connect with ado, using jet 4.0
__________________
"Never explain--your friends do not need it and your enemies will not believe you anyway."
Elbert Hubbard (1856 - 1915)
Reply With Quote
  #3  
Old 02-13-2003, 01:32 PM
Jquiz
Guest
 
Posts: n/a
Default

I am using the ADODC control and I can connect but I can not display information in a listBox.

I can get data into a text box, What I want to do is display the first and last names, which are seperate fields in the table. I have gotten as far as trying to concatenate the data from each text boxes into one but I haven't gotten that far yet. It would be so much easier if I could get the data from both fields to display inside a list box.

It's rather frustrating, this should work. I am baffled.
Q
Reply With Quote
  #4  
Old 02-13-2003, 01:48 PM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

Update your version of VB6 to Service Pack 5
Reply With Quote
  #5  
Old 02-13-2003, 01:51 PM
Jquiz
Guest
 
Posts: n/a
Default

I did that an hour ago but I will reapply the service pack.
Q
Reply With Quote
  #6  
Old 02-13-2003, 02:30 PM
vbNEMESIS's Avatar
vbNEMESIS vbNEMESIS is offline
Junior Contributor
 
Join Date: Jan 2003
Location: PA
Posts: 312
Default

list1.additem adodc1.recordset.fields("FirstName") & " " & adodc1.recordset.fields("LastName")
__________________
"Never explain--your friends do not need it and your enemies will not believe you anyway."
Elbert Hubbard (1856 - 1915)
Reply With Quote
  #7  
Old 02-13-2003, 04:07 PM
Jquiz
Guest
 
Posts: n/a
Default

Hey thanks that got the recods into the list box, but I am still unable to move the record from the list box to the text box. Here is the code I am using ...

Private Sub OKButton_Click()
lstPtnm1.additem adodc1.recordset.fields("First_Name") & " " & adodc1.recodset.fields("Last_Name")
If lstPtnm1.ListIndex = 0 Then
YellowSheet.txtPtNm.Text = " "
Else
YellowSheet.txtPtNm.Text = lstPtnm1.List(lstPtnm1.ListIndex)
End If
End Sub

YellowSheet is the name of the form with the text box named txtPtNm
lstPtnm1 is the list box where the records from your code go, this is on form Dialog

I can run the program with this code and I don't get an error but I also don't get any data moving from the list box to the text box.

any suggestions?
Q
Reply With Quote
  #8  
Old 02-14-2003, 08:19 AM
vbNEMESIS's Avatar
vbNEMESIS vbNEMESIS is offline
Junior Contributor
 
Join Date: Jan 2003
Location: PA
Posts: 312
Default

Dim c As Long
c = InStr(1, List1.Text, " ") ' <~ Here we find the space in the listbox text
Text1.Text = Left(List1.Text, c - 1)' <~ Populate text1 with the text to the left of the space
Text2.Text = Right(List1.Text, c + 1)' <~ Populate text2 with the text to the right of the space

Maybe this will help.
__________________
"Never explain--your friends do not need it and your enemies will not believe you anyway."
Elbert Hubbard (1856 - 1915)
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->