borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (SQL Syntax)Next Topic (ADO malfunction???) New Topic New Poll Post Reply
AndreaVB Forum : Database : Create Textbox for finding data in database
Poster Message
DianeJ
Level: Protégé

Registered: 01-08-2006
Posts: 5

icon Create Textbox for finding data in database

I have created a database (an address book) with Access, and I used the wizard in Access to create a query.  I have put two textboxes on my form, 1 for First Name and 1 for Last Name where I can type in a persons name (either first or last), press a button ive called "find" and have it bring up that persons details from my database.  The problem is is that I have read so many posts on various forums and articles etc and am totally confused and do not know where to start.  Could somebody please give me some help as to where to start re coding these textboxes and my find button.  I am using Visual Basic 2005 express edition.

01-08-2006 at 11:42 PM
View Profile Send Email to User Show All Posts | Quote Reply
elric
Level: Scholar


Registered: 09-07-2006
Posts: 35
icon Re: Create Textbox for finding data in database


'-----------------------------
Private Sub cmdFind_Click()
Dim fiNd2 As Variant

Adodc1.Refresh
If Text1.Text = "" Then ' this will check if the textbox1 is empty or not
' well if it is empty then this msgbox will appear and get out of the sub...    
MsgBox "No value given for one or more required parameters", vbExclamation + vbOKOnly, ""
Exit Sub
Else
    'this will put the text1.text into a container,,nothing i just want to put it there hahah,,
    fiNd2 = Text1.Text
    Adodc1.Refresh
    Adodc1.RecordSource = "select * from Membership where FirstName like'" & fiNd2 & "%'"
        Adodc1.Refresh
        If Adodc1.Recordset.RecordCount = 0 Then
' this will see if the database is empty if it is this what will happen...
    MsgBox "Record Not Found"
            Adodc1.Refresh
    Exit Sub
        Else
    'if your app found the record it will now distribute all info from 0-3 fields...
            Text2.Text = Adodc1.Recordset.Fields(0).Value
            Text3.Text = Adodc1.Recordset.Fields(1).Value
            Text4.Text = Adodc1.Recordset.Fields(2).Value
            Text5.Text = Adodc1.Recordset.Fields(3).Value
        End If
End If
End Sub
'------------------------------


oh i guess you already know how to put your database in an Adodc right? heheh.. thats all...      

____________________________
-same thing over and over again..-

03-08-2006 at 05:02 PM
View Profile Send Email to User Show All Posts | Quote Reply
Gary
Level: Sage

Registered: 27-11-2005
Posts: 50
icon Re: Create Textbox for finding data in database

May I know how can I display each value in each textbox? Let say the table consists of:

xxxxx1   abc
xxxxx2   123
xxxxx3   def

"xxxxx1   abc" will be displayed in textbox1
"xxxxx2   123" will be displayed in textbox2
"xxxxx3   def" will be displayed in textbox3

Thank you...


Gary

15-10-2006 at 06:22 PM
View Profile Send Email to User Show All Posts | Quote Reply
elric
Level: Scholar


Registered: 09-07-2006
Posts: 35
icon Re: Create Textbox for finding data in database

have you tried the code..?  try it..

____________________________
-same thing over and over again..-

30-10-2006 at 08:36 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : Create Textbox for finding data in database
Previous Topic (SQL Syntax)Next Topic (ADO malfunction???) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder