|
-
Mar 24th, 2008, 04:34 AM
#1
Thread Starter
New Member
Search For Record
hello, i am a newbie in programming.
i am creating a simple database program right now with a single table using ms access.
i already finished some of its functions like add, save, delete, exit etc. my problem right now is i do not know how to search a particular record in my database and display its result to a table form in a datagrid. here is what i have so far...
Code:
Private Sub cmdSearch_Click()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\contact.mdb;Persist Security Info=False"
Set rs = cn.Execute("SELECT * FROM Table1 WHERE contact Id = '" & txtContId.Text & "'")
DataGrid1.DataSource = rs
DataGrid1.Refresh
End Sub
What I would like to do is to a search a particular contact Id that is to be inputted in the txtContId.text and then show its other details in a table form using datagrid1.
I hope somebody could help me with this....thank you in advance!
God bless!
-
Mar 24th, 2008, 05:41 AM
#2
Re: Search For Record
Split into its own thread
If you wish to contribute to the answer to someone else's question, then by all means, post in their thread.
If, however, you have a question of your own, please create your own thread.
Thanks.
-
Mar 24th, 2008, 06:26 AM
#3
Lively Member
Re: Search For Record
Ok, The problem was I was not populating the Id Text box before calling the SQL statement. The Program is running fine now with the statement
Code:
NavigateRecords()
sqll = "SELECT * FROM branches WHERE Company_ID= " & IDText.Text
-
Mar 24th, 2008, 07:19 AM
#4
Lively Member
Re: Search For Record
I will look into tagheuer34's question as soon as possible. I am planning to incorporate a search for my project as well.
-
Mar 24th, 2008, 10:53 PM
#5
Thread Starter
New Member
Re: Search For Record
I will really wait for your suggestions regarding my problem in my code.
Thank you in advance for any possible help that will be given.
-
Mar 25th, 2008, 03:36 AM
#6
Re: Search For Record
What problem would that be?
So far you haven't told us what it is, so we can't really help you correct it.
One obvious problem is that you have a field called "contact Id", which is a really bad idea - names with spaces in cause a lot of problems, so you should change it if possible (perhaps to "ContactId").
-
Mar 25th, 2008, 04:11 AM
#7
-
Mar 25th, 2008, 08:46 PM
#8
Thread Starter
New Member
Re: Search For Record
ok,
my problem with the code I've given is that it is not giving any output. It results in an error "Data Member Not Found".
That's why my question is what can anybody suggest to make my code produce result. And the result should be to output the other information of a partricular contact (name, address etc) by inputting it's contact Id in the contId textbox.
thanx!
-
Mar 25th, 2008, 10:33 PM
#9
Member
Re: Search For Record
Hi again Tagheuer34,
Try to use Set keyword..Try this one,
Set Datagrid1.datasource = rs
Hope this helps
-
Mar 26th, 2008, 08:30 PM
#10
Thread Starter
New Member
Re: Search For Record
hello krizaaa,
thank you very much for your help. you're very kind.
anyway, my problem was already solved. I used MSHFlexGrid instead of DataGrid to output my table to my form.
thanks again....God bless!!!
-
Mar 27th, 2008, 02:31 AM
#11
Member
Re: Search For Record
You're welcome..
Anyways, I have tried your code and I also got "Data Member Not Found" error. Then I used Set datagrid1.datasource = rs. Learned that data source should be set. Then it works fine with the datagrid.
You can try this in the future or for experimenting. Just sharing what I've learned..
Thanks..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|