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...
-
Option Explicit
-
Option Base 1 'this option makes it that the program starts at number 1, always...
-
Dim io() As String 'dimensioning for array to return values
-
Dim prs_calc As Integer 'dimensioning to record person instances
-
Dim ndvdl, filenum1 As Integer 'dimensioning to record instances for each instance of a person
-
Dim my_string As String
-
'Your input box for instances being entered
-
'Your buttons will disapear depending on number added in for each entry
-
Private Sub Form_Load()
-
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
-
-
'making sure only digits are entered
-
If IsNumeric(ndvdl) = False Then
-
MsgBox ("Please add numeric data to continue...")
-
'LoadTFile.Visible = False
-
Else 'If IsNumeric(Text3.Text) = True Then
-
-
ReDim io(ndvdl, 5) 'redimensioned for the purpose of data rows calculator
-
prs_calc = 1
-
End If
-
End Sub
-
-
'this is searching for existing data in local Access database
-
Private Sub Seek_Click()
-
Dim my_database As Database 'dimension database as database so program knows where to look for data
-
Dim my_record As Recordset
-
Dim test As String
-
test = Text1(1).Text
-
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)
-
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
-
Do While Not my_record.EOF 'this function will keep searching for fields matching each textbox
-
'MsgBox ("got here")
-
Text1(0).Text = my_record.fields("Your_Price")
-
Text1(1).Text = my_record.fields("Name")
-
Text1(2).Text = my_record.fields("Type")
-
Text1(3).Text = my_record.fields("Crime_Rate_1")
-
Text1(4).Text = my_record.fields("Crime_Rate_2")
-
-
my_record.MoveNext
-
Loop
-
my_database.Close
-
End Sub
-
-
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