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 (Conditional Insert)Next Topic (How get the code source (with dhtml, javascript) from a web page ?) New Topic New Poll Post Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : retrieving data from database
Poster Message
Aya
Level: Protégé

Registered: 31-01-2006
Posts: 8

icon retrieving data from database

does anyone knows the coding for retrieving data through the form. i mean function for button search. the situation is like this; i wanna display the certain record from databse. so, i will enter the key into the field such as IC number, when i click search button it will display the record for such IC at the field so that i can alter that recoords....


____________________________
i love learning new things.....

06-02-2006 at 08:50 AM
View Profile Send Email to User Show All Posts | Quote Reply
xtramac
Level: Professor


Registered: 28-08-2005
Posts: 89
icon Re: retrieving data from database

hello,

try this it might help....

dim rs as new adodb.recordset

rs.open "Select * from tblName where ic = '" & text1.text & "'",activeConnection,adopenforwardonly, adlockreadonly,adcmdtext

text2.text = rs.field(0)
text3.text = rs.field(1)
etc..

you have to close rs..

rs.close
set rs = nothing



  

andrew

07-02-2006 at 06:24 AM
View Profile Send Email to User Show All Posts | Quote Reply
Aya
Level: Protégé

Registered: 31-01-2006
Posts: 8
icon Re: retrieving data from database

thanks a lot xtramas, i've forgot to state that i'm using EXCEL VBA. so, i dont use any db as you write the coding that include ADODB.
all entry data will saved in datasheet..
so, can i use your coding?

____________________________
i love learning new things.....

09-02-2006 at 05:29 AM
View Profile Send Email to User Show All Posts | Quote Reply
~Bean~
Level: VB Guru


Registered: 07-04-2003
Posts: 488
icon Re: retrieving data from database

So you're not using a database, just Excel...?

This is straight from Help (with a little tweak)...you may want to look into using Find.


Dim intIC As Integer

With Worksheets(1).Range("a1:a500")
    Set c = .Find(intIC, LookIn:=xlValues)
    If Not c Is Nothing Then
        firstAddress = c.Address
        Do
            MsgBox("Found " & intIC & " at " & c.Address)
            Set c = .FindNext(c)
        Loop While Not c Is Nothing And c.Address <> firstAddress
    End If
End With


[Edited by ~Bean~ on 16-02-2006 at 08:46 AM GMT]

____________________________
Eggheads unite! You have nothing to lose but your yolks.

16-02-2006 at 01:45 PM
View Profile Send Email to User Show All Posts Visit Homepage | Quote Reply
AndreaVB Forum : VBA (Access, Excel, Word, ...) : retrieving data from database
Previous Topic (Conditional Insert)Next Topic (How get the code source (with dhtml, javascript) from a web page ?) 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