Solved

Updating form using DBComboBox

Posted on 1998-11-17
4
378 Views
Last Modified: 2013-12-25
I have an application where I have created a Data Environment, Connection and Commands from a SQL database.  The form has several numerous textboxes that are bound to the this data environment.  I have added a DBComboBox and I am able to fill it with the 'Name' field, I have the BoundColumn set to the 'ID' as it is the Primary Key in the database.  When I change the selection in the combobox I want all of the fields to update with the new selection.  So far I haven't been able to do this.  I have tried using the recordsets Move, Bookmark and some other combinations and I am having no luck.  I am sure I am missing something here.  Help!
0
Comment
Question by:MTroutwine
[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
4 Comments
 
LVL 13

Expert Comment

by:Mirkwood
ID: 1488337
Fill in the listfield and datafield  property of the DBCombo1

set Dbcombo1.datasource = data1
DbCombo1.Datafield = "Author"
DbCombo1.ListField = "Author"
DbCombo1.matchentry = 1
DbCombo1.style = 2
0
 
LVL 3

Author Comment

by:MTroutwine
ID: 1488338
I am able to fill the combobox, what I am looking for is when you change the selection in the combobox updating all of the other textboxes on the same form with the current recordset.  What is happening now is I change the combobox selection and it doesn't update the form.  I am using VB6, I am setting the DataCombo properties of DataSource, DataMember, DataField, RowSource, RowMember, ListField and BoundColumn.  I have setup a Data Environment with one connection and one command.  I tried using DataCombo1.SelectedItem and I get error messages that the columns have not been modified no changes are made closing application.  Hope this helps, sorry for such poor detail before.
Thanks,

0
 
LVL 12

Expert Comment

by:jgv
ID: 1488339
Try this:

Private Sub DBCombo1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
searchstring = "NAME = '" & DBCombo1.Text & "'"
Data1.Recordset.FindFirst searchstring
End Sub
0
 
LVL 2

Accepted Solution

by:
cedricd earned 100 total points
ID: 1488340
use a data control
events :
private sub dbcombo1_click(area as integer)
        if area = 2 then
           data1.recordset.findfirst("id ='"+dbcombo1.boundtext+"'")
           textbox1.text = data1.recordset(1)
           etc...
        end if
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

730 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