Connecting Tech Pros Worldwide Forums | Help | Site Map

Data management with XML, Text files using VB 6.0: Part One

Dököll's Avatar
Moderator
 
Join Date: Nov 2006
Location: Upstate NY - US
Posts: 2,270
#1   Mar 1 '08
Continued from:

http://www.thescripts.com/forum/thread762010.html

-VB 6.0 Professional
-Microsoft DAO 3.6 Reference

Search Database table...

An attempt to fetch data housed in Access:

(1) This program attempts to search actual data in an Access database
(2) Build an Access database table with 5 text fields
(3) Read code below, add these fields starting with Your_Price as names
(4) Each field must correspond with the field names shown here in VB
(5) You must have an array of 5 textboxes, first in line Text1(0).Text
(6) You will need a fancy command button called whatever you want, 'Seek'
(7) ADD Microsoft DAO 3.6 Object Library
(8) Add code below...

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Option Base 1 'this option makes it that the program starts at number 1, always...
  3. Dim io() As String 'dimensioning for array to return values
  4. Dim prs_calc As Integer 'dimensioning to record person instances
  5. Dim ndvdl, filenum1 As Integer 'dimensioning to record instances for each instance of a person
  6. Dim my_string As String
  7. 'Your input box for instances being entered
  8. 'Your buttons will disapear depending on number added in for each entry
  9. Private Sub Form_Load()
  10. ndvdl = Int(InputBox("Add a number to box to continue", "Data Mining Required Info", 1)) 'this is the pop-up box for entry of persons by the user
  11.  
  12. 'making sure only digits are entered
  13. If IsNumeric(ndvdl) = False Then
  14.     MsgBox ("Please add numeric data to continue...")
  15.     'LoadTFile.Visible = False
  16.     Else 'If IsNumeric(Text3.Text) = True Then
  17.  
  18. ReDim io(ndvdl, 5)  'redimensioned for the purpose of data rows calculator
  19.     prs_calc = 1
  20.     End If
  21. End Sub
  22.  
  23. 'this is searching for existing data in local Access database
  24. Private Sub Seek_Click()
  25. Dim my_database As Database           'dimension database as database so program knows where to look for data
  26. Dim my_record As Recordset
  27. Dim test As String
  28. test = Text1(1).Text
  29. Set my_database = OpenDatabase("C:\DataGram\Data_Central.mdb")   'this function will open the database using the link to the access database (provided that it is closed access)
  30. Set my_record = my_database.OpenRecordset("SELECT * FROM LIBRARY WHERE Your_Price LIKE '" & Text1(0).Text & "'")    ' this is used to search by name, only if data already exists
  31.    Do While Not my_record.EOF  'this function will keep searching for fields matching each textbox
  32.    'MsgBox ("got here")
  33.         Text1(0).Text = my_record.fields("Your_Price")
  34.         Text1(1).Text = my_record.fields("Name")
  35.         Text1(2).Text = my_record.fields("Type")
  36.         Text1(3).Text = my_record.fields("Crime_Rate_1")
  37.         Text1(4).Text = my_record.fields("Crime_Rate_2")     
  38.  
  39.    my_record.MoveNext
  40.    Loop
  41.    my_database.Close
  42. End Sub
  43.  
  44.  
TIP: Download SQL Server Management Studio Express to manage data from ASP.NET/SQL DB:

http://www.thescripts.com/forum/thread762010.html

SQL Server Management Studio Express helps load data gathered there to local Access DB, or vice versa...

SQL Server Management Studio Express facilitates query building. Use the query builder, appropriately named, to allow querying Access databases and others.

The SQL Server management tool is essential to the data that must be available to VB/VBA for futher observation. Please download SQL Server Management Studio to make data available to VB/VBA applications

http://www.microsoft.com/downloads/d...displaylang=en

Submit Button Next...

Click here to get there quickly: http://bytes.com/forum/thread777271.html

Last edited by Dököll; Apr 13 '08 at 03:53 AM. Reason: title modified, Form_Load code...



Reply