Solved

Getting random information from a database

Posted on 2002-04-09
6
160 Views
Last Modified: 2010-05-02
           

           1st textbox   =  Name
            2nd textbox =  Father?s name
            3rd textbox  =  House No
            4th textbox =   Street No
            5th textbox =   City
               
   Over here I have got five textboxes(on a vb form) showing addresses of a city.
    How can I get ?Name?  ?Fathername? ?Street? and City by writing only the ?House No? and  Clicking for example I want to get information about house no 123 ,  50 and  780  one at a time from the connected Database.
 
0
Comment
Question by:HIKER
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:telebasics
ID: 6929856
using SQL a statement like:
SELECT * FROM database WHERE streetno IN '123','50','780'

not sure about the IN but something like that.
0
 

Author Comment

by:HIKER
ID: 6929916
   
    Not answered yet
0
 

Accepted Solution

by:
humbk2002 earned 50 total points
ID: 6930645
Below is the solution,House no should be shown in a combo box,because you are to use it to make selections,the house numbers will be shown on the combo box,so with that you can select a house no,and then the rest can be shown on the separate text boxes,but try this code:


---------------------------Load the Form`````````````````
Private Sub Form_Load()
Set db = OpenDatabase("Yourdatabase.mdb")
Set RS = db.OpenRecordset("tabel or query to show the items")
Do While RS.EOF = False
'cmbHouseno is the combo box name and Houseno is the table 'or query field so add it

cmbHouseno.AddItem RS!Houseno

RS.MoveNext
End Sub

-------------The function to show the next fields`````
Public Function FillRelated_Information()
Dim found as Boolean
found = False
If cmbHouseno <> "" Then
Set db = OpenDatabase("Yourdatabse.mdb")
Set RS = db.OpenRecordset("table/query")
Do While Not RS.EOF And Not found
If cmbHouseno = RS!HouseNo Then
found = True
Else
RS.MoveNext
End If
Loop
End If
If found = True Then
'Put the data into the text boxes and combo box
 'Put the contents in the appropriate boxes
txtName=RS!Name
txtfathername=RS!Fathersname
txtCity=RS!City
RS.Edit
cmbHouseno=RS!Houseno

RS.Update
End If
End Function

```````````````````````Call Function```````````````
Private Sub cmbHouseno_click()
Call FillRelated_Information
End sub
```Hopes it helps`````````````````````````````````

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Expert Comment

by:humbk2002
ID: 6930646
include also this code

txtStreetno=RS!Streetno
0
 

Author Comment

by:HIKER
ID: 6932262
   I want to make it simple
   On a vb form I have a data control which is connected to
  ?NWIND? (the sample data which comes with vb) I have
  chosen ?employees? from data source.
  I have got six textboxes showing 1 employees ID  
  2 last name 3 first name 4 title 5 title of courtesy
  6 birthday it is working ok I can scroll from id no 1 to id  
   no 9  but I want to write the id no of my choice and get
   other related information in other textboxes.
     
   
0
 

Author Comment

by:HIKER
ID: 6932267
 oops
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question