Aya Level: Protégé Registered: 31-01-2006 Posts: 8
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
|
xtramac Level: Professor Registered: 28-08-2005 Posts: 89
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
Aya Level: Protégé Registered: 31-01-2006 Posts: 8
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
|
~Bean~ Level: VB Guru Registered: 07-04-2003 Posts: 488
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.