Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Database-??

Status
Not open for further replies.

theshadowknz

Programmer
Aug 30, 2002
10
US
I have a combo list box (vendors names) that when vendor is selected would like remaining data from database (address, phone, city, state, etc)., to fill in labels on form for thaqt vendor. Have looked at a few other and "made" my dat the same,etc, but it just doesn't seem to work for me. What doing wrong?????
 
How on earth are we supposed to know. We aren't mind readers.
Peter Meachem
peter @ accuflight.com

 
What is your data structure like? Is it a single table?
Are you loading your combo from a SQL statement? using ADO?

Just pick up selected item from combo, stick it into SQL select statement and load text boxes from recordset

When we've got the answers to the above questions, we can be more specific in answer Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Single table-Access 2000;
DAO control; followed coding from address/phone book.
Here is code:

Private Sub cboTech_Change()
datTech.RecordSource = _
"SELECT * FROM Tech WHERE TechSupport ='" & _
cboTech.Text & "'"

'datTech.Refresh

End Sub

Private Sub cboVendor_Change()

datVendor.RecordSource = _
"SELECT * FROM Vendor WHERE Vendor ='" & _
cboVendor.Text & "'"

datVendor.Refresh

End Sub

Private Sub cmdPrint_Click()
'Prints purchase order


End Sub
Private Sub Form_Load()

Dim dbname As String
Dim db As Database
Dim rs As Recordset

' Open the database.
dbname = App.Path
If Right$(dbname, 1) <> &quot;\&quot; Then dbname = dbname & &quot;\&quot;
dbname = dbname & &quot;tech.mdb&quot;

Set db = OpenDatabase(dbname)
Set rs = db.OpenRecordset( _
&quot;SELECT TechSupport FROM Tech ORDER BY TechSupport&quot;, _
dbOpenSnapshot)

' Load the ComboBox.
rs.MoveFirst
Do While Not rs.EOF
cboTech.AddItem rs!TechSupport
rs.MoveNext
Loop

rs.Close
db.Close

' Connect the Data control to the database.
datTech.DatabaseName = dbname

' Select the first choice.
cboTech.ListIndex = 0

' Open the database.
dbname = App.Path
If Right$(dbname, 1) <> &quot;\&quot; Then dbname = dbname & &quot;\&quot;
dbname = dbname & &quot;vendor.mdb&quot;

Set db = OpenDatabase(dbname)
Set rs = db.OpenRecordset( _
&quot;SELECT Vendor FROM Vendor ORDER BY Vendor&quot;, _
dbOpenSnapshot)

' Load the ComboBox.
rs.MoveFirst
Do While Not rs.EOF
cboVendor.AddItem rs!Vendor
rs.MoveNext
Loop

rs.Close
db.Close

' Connect the Data control to the database.
datVendor.DatabaseName = dbname

' Select the first choice.
cboVendor.ListIndex = 0
End Sub

 
Sorry but it's quite hard to work out what you want from your code alone.

When you say 'single table' do you mean Tech table or Vendor table or two tables? If two, how are they connected? If one, which one and what's the other stuff?
How many textboxes do you have, and what do you want in them?
What fields are in your table(s)? Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Okay--I think I understand better now--I have two separate tables, one named Tech and one named Vendor. The database in each table is named the same also. The Combo box is in two separate frames--cboTech and cboVendor. In Frame 1- Clicking on cboTech--you get a drop down list of all our tech support's name--selecting a name is supposed to fill in the remainder of the labels in the frame, ie: the labels are: Line 1: Department of Transportation (permanent). Line 2: Department. Line 3: (cboTech-is here) & Phone. Line 4: Section, Line 5: AddressOne, Line 6: AddressTwo, Line 7: City, Sate, Zip
The same for frame2-cboVendor. You don't need the fields matched to the label do you?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top