Solved

Getting random information from a database

Posted on 2002-04-09
6
169 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel - Save a copy of work book 13 96
Hide vba in gp 7 127
TT Auto Dashboard 13 104
How to read File Date Created using VB6 8 71
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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
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…

739 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