944,165 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Aug 1st, 2006
0

access database search and display

Expand Post »
hello all
i m new to this topic, though I have some experience of using VB to control excel.
I have an access database which has some records. The columns(fields) are first name, lastname, year of birth, city, county, district, state, tel ph number and email id.
Now I want to write a vb code through which the user will search for a person's year of birth(there r multiple people with same year of birth). after this the form shud display the the name of the district in which those persons having the searched year of birth, live. from the list the user wud select the district he wants and the counties within that district shud be displayed. and after selecting a particular county.. the cities within that county shud be displayed.and finally when the user select any of those cities, the email id and the ph number of the matching person(s) shud be displayed.

Comatose.. I have gone thru the link u have given, but cudnt make out much from that. I m really new to this, and any help wud be much appreciated.
thanks.
shefali.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
Shefali is offline Offline
36 posts
since Apr 2006
Aug 1st, 2006
0

Re: access database search and display

Do you already have code for this (naturally, not all of it, or you wouldn't be asking) but my question is... have you started the project?

The layout of how I would go about it, is I would make a query for the birth year, and then retrieve all the information about each record for that birth year.....so, if they search by 1979, the database would return a list of records for 1979. Then I would store all the information in arrays for every record in 79, and sift through it in the vb code..... let me know where you are with this, and where I can help.
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Aug 1st, 2006
0

Re: access database search and display

thanks for ur reply comatose. actually i havent yet started the project. i am looking around to get some help to get myself started. i m not very sure how do i link access 2003 and vb6.. i mean do i use ado or shud i use the something similar to what is done to link vb and excel.
so once this gets clear to me maybe then i can start with the project.
but i m sure i wud need lots of help.. as i m really new to this.
thanks again.
Reputation Points: 10
Solved Threads: 0
Light Poster
Shefali is offline Offline
36 posts
since Apr 2006
Aug 1st, 2006
0

Re: access database search and display

Definately ADO. How well versed are you in the VB Language? A lot of times, people who understand little about programming at all want to take on pretty hefty tasks.... I'm not insinuating that you are doing that, I just want to make sure that I don't throw too much stuff in the mix that you haven't yet learned.... that said, I'll give a brief explanation of ADO.

ADO is a bunch of classes that allow you to make an object, so that you can connect to a database. You might only need one of the classes, or all of them. Anyway, the first thing you need to do is tell VB you want to use the database system. So, we go to up to the project menu, then references..... once the new window opens scroll down and find "Microsoft ActiveX Data Objects 2.5 Library" or the "Microsoft ActiveX Data Objects 2.6 Library". If you don't have them, your code will not work. Which means you probably don't have access installed on the box or something. Anyway, moving on.

Once VB knows we want to use those classes, we can make objects of them. So first, we need to define the variables that we will use to work with the database.
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim conConnection As New ADODB.Connection
  2. Dim cmdCommand As New ADODB.Command
  3. Dim rstRecordSet As New ADODB.Recordset
The first line, is going to make a variable that will let us connect to the database. The second one, will allow us to submit a query, and the last one will define how the record should be returned. Then you have to define a connection string. Really this is a pretty lengthy process.

The attachment is a tutorial in code that I found while surfing around, it might be helpful to you.... it's pretty much a skeleton of how to make VB work with ADO
Attached Files
File Type: zip CODE_UPLOAD1065010142000.zip (14.0 KB, 1565 views)
Team Colleague
Reputation Points: 361
Solved Threads: 214
Taboo Programmer
Comatose is offline Offline
2,413 posts
since Dec 2004
Aug 2nd, 2006
0

Re: access database search and display

thank u very much comatose. i will go through the attached file and will try my best to do whatever i can. as far as my vb skills are concerned i m not really very good, but yea i have done some coding and linking vb to other applications like excel and labview.
i hope to get ur guidance if i get messed somewhere.
thanks a lot.
Reputation Points: 10
Solved Threads: 0
Light Poster
Shefali is offline Offline
36 posts
since Apr 2006
Aug 2nd, 2006
0

Re: access database search and display

i have gone thru the tutorial code and also written my code based on that. as of now i can link my database and also retrieve a data of my choice and display it in a text box.
now what i want is that all data in a certain field to be displayed fully and after that the user can search from that list so that additional narrowed down information wud be displayed.
comatose ur help was invaluable to get me upto this... can u plz guide me further?
hoping to get a reply from u or any other members who wud like to help me a bit.
thanks.
Reputation Points: 10
Solved Threads: 0
Light Poster
Shefali is offline Offline
36 posts
since Apr 2006
Aug 8th, 2006
0

Re: access database search and display

seems no one is interested to give me some suggestions or help me.
anywayz..
i have written a code using ado which connect a access database and searches a particular field and displays relevant information from the search results. for instance if the user searches the fone number, if matches then the persons last name, first name and email id is being displayed.
however i want to narrow down the search, like say the user enters the last name, then all the person matching wud be displayed in a listbox and from that if the user clicks one of those persons, subsequesnt information wud be displayed in another list box and so on.
can someone plz help me in this regard.
thanks.
Reputation Points: 10
Solved Threads: 0
Light Poster
Shefali is offline Offline
36 posts
since Apr 2006
Feb 10th, 2010
0

Searching in the database

Hi,

I got just that far, and I'm even able to add records, that's no problem. Now I've got the problem that my program can't find them back (properly).

My code (simplified) is:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub frmMain_Load()
  2.  
  3. Dim dbReminder As Database
  4. Dim rsBirthdays As Recordset
  5.  
  6. Do
  7. rsBirthdays.FindFirst "fieldDate = Date"
  8. MsgBox((rsBirthdays!fieldName) & " is celebrating his/her birthday today.")
  9. rsBirthdays.Delete
  10. 'I delete the record, to prevent it from seeing it again, when the
  11. 'loop has completed. If i wouldn't do this, it would keep giving a
  12. 'MsgBox, until the date has changed.
  13. Loop
  14.  
  15. End Sub

The problem is that it gives a MsgBox with every record it can find.
By example: If there is only ONE record in the entire table (with the value "Test" in fieldDate, so just a string), my program thinks its equal to the date.. I tried everything i could find on the web, but it still gives the same problem..

Please help!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Quick-T is offline Offline
5 posts
since Feb 2010
Feb 10th, 2010
0
Re: access database search and display
hi,
i m too new in VB n fasing similar problem i tried to open attachment but failed...can u plz send me extracted 1..if u had open?


Click to Expand / Collapse  Quote originally posted by Shefali ...
thank u very much comatose. i will go through the attached file and will try my best to do whatever i can. as far as my vb skills are concerned i m not really very good, but yea i have done some coding and linking vb to other applications like excel and labview.
i hope to get ur guidance if i get messed somewhere.
thanks a lot.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
supriya_priti is offline Offline
3 posts
since Feb 2010
Feb 10th, 2010
0
Re: access database search and display
hmmm... not sure... but should that not be fieldDate = " & Date ???



Good Luck
Reputation Points: 156
Solved Threads: 296
Posting Virtuoso
vb5prgrmr is offline Offline
1,670 posts
since Mar 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Front End Design
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Bind ListBox to ADODB.Recordset





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC