Solved

Getting random information from a database

Posted on 2002-04-09
6
150 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

786 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