|
-
Dec 22nd, 2005, 10:15 AM
#1
Thread Starter
New Member
DataList jumps to next in list
I have solved my previous problem but face a new one now. Perhaps someone can help.
I have a MS SQL 2000 database. I use two tables from that database. Two different ADOdc's connect to a table. One table contains information about companies and the other contains contactpersons from those companies.
In my form I have a DataCombo with following properties:
BoundColumn = Companyname
DataField = Companyname
Datasource = Contactpersons
ListField = Companyname
RowSource = Companies
Also in my form is a DataList and properties are:
BoundColumn = Companyname
DataField = NameOfContact
Datasource = Contactpersons
ListField = NameOfContacts
RowSource = (is empty)
A third ADOdc called Name, is used to store the rows that are the same in both tables, resulting in a list of contactpersons for a specific company.
Code in the form is:
VB Code:
Option Explicit
Private DeleteContact As String
Private Sub DataCombo1_change()
Dim query As String
gstrContact = DataCombo1.Text
query = "SELECT * FROM Contactpersons WHERE CompanyName = '" & gstrContact & "' ORDER BY Name"
Name.RecordSource = query
Name.Refresh
Set DataList1.RowSource = Name
DataList1.Refresh
End Sub
Private Sub Form_Load()
ContactPersons.Recordset.AddNew
DataCombo1.Text = ""
End Sub
Now what is the problem?
When the form opens, I can go to DataCombo1 and select a company. When a company is chosen, all the contacts of that company are visible in DataList1.
I then select a name by clicking it.
And then the problem comes.
When I push a button that I have on my form, the NEXT name in my DataList1 gets selected. Why, I don't know. It's like a lostfocus was written somewhere to jump to the next one in the list. I cannot seem to find the solution.
I wanted to delete the selected person, but because the next one in the list gets selected when I push the delete button, the wrong person gets deleted.
Good thing I made a backup of my database before trying this.
Anyone who can help?
-
Dec 22nd, 2005, 08:45 PM
#2
Re: DataList jumps to next in list
 Originally Posted by pthomass
When I push a button that I have on my form, the NEXT name in my DataList1 gets selected.
Would you post the code for tat button?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|