473,769 Members | 2,346 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

listbox and linking to database

Hello,
I have a form with a listbox that displays a list of records from a SQL table. When one of these is selected, another listbox is populated with data from a SQL table that is linked to the 1st table.
I'm not sure what I'm doing wrong, but when you first click on a value in listbox1, it shows a list of values in listbox2 that are linked with the PREVIOUS value in listbox1, (basically the ID of the listbox item - 1) then, if you click the listbox1 value AGAIN, it shows the correct records.
I'm using the listbox1_Select edIndexChanged( ) sub.
Is this where the problem lies?
Thanks,
amber

Nov 20 '05 #1
7 1499
Post your code so we can see what you're up too.
It could be anything but what you're trying to do is very simple
so when we've seen your code you'll get an answer lickety split.

At least you've identified a pattern to the bug so you probably
already have 3/4 of the answer yourself in such a simple scenario.

Post some code and we'll get it sorted.

Richard
Nov 20 '05 #2
Thanks Richard
This doesn't seem to want to work for me. I tried replying a few times last week, and creating a new post...but they never appeared
So here goes again..

Private Sub lBoxCP_Selected IndexChanged(By Val sender As System.Object, ByVal e As System.EventArg s) Handles lBoxCP.Selected IndexChange
'load cutblock lis
lBoxCB.DataSour ce = Nothin
Me.txtBox1.Data Bindings.Clear(
Me.txtBox2.Data Bindings.Clear(
Me.txtBox3.Data Bindings.Clear(

OleDbDataAdapte r3.SelectComman d.Parameters("I D_CUTTING_PERMI T").Value = txtCPID.Tex
DsCutBlock1.Cle ar(
OleDbDataAdapte r3.Fill(DsCutBl ock1
lBoxCB.DataSour ce = DsCutBlock
lBoxCB.DisplayM ember = "TDT_CUT_BLOCK. STR_BLOCK_NUMBE R

Me.txtBox1.Data Bindings.Add(Ne w System.Windows. Forms.Binding(" Text", Me.DsCutBlock1, "TDT_CUT_BLOCK. STR_BLOCK_NUMBE R")
Me.txtBox2.Data Bindings.Add(Ne w System.Windows. Forms.Binding(" Text", Me.DsCutBlock1, "TDT_CUT_BLOCK. NUM_AREA_APPROV ED")
Me.txtBox3.Data Bindings.Add(Ne w System.Windows. Forms.Binding(" Text", Me.DsCutBlock1, "TDT_CUT_BLOCK. STR_LOCATION")

End Su
Nov 20 '05 #3
Cor
Hi Amber,

I will not say it is the only thing, but this is one of the things that is
not correct.
Me.txtBox3.Data Bindings.Add(Ne w System.Windows. Forms.Binding(" Text", Me.DsCutBlock1,
"TDT_CUT_BLOCK. STR_LOCATION"))

You have to bind it to the table not to the dataset.

I asume it is a typed dataset so just the dot and than the table name,

Although probably
DsCutBlock1.tab les(0) will works also if you have only one table.

I hope this helps,

Cor
Nov 20 '05 #4
Cor
Hi Amber,

You are right, I did not see the dot between the second parameters.

I did look very long and see not direct something wrong, but in your problem
you are talking about listbox1 and listbox2 and it is very hard to find what
goes wrong.

Can you tell it again but now with the right names?

Cor

Nov 20 '05 #5
Cor
> I did look very long and see not direct something wrong, but in your
problem
problem = problem description (the first message)
Nov 20 '05 #6
I appreciate all your help

Having problems posting again...my most recent reply never did show up..

Okay,

My original message (with edits)
I have a form with a listbox (lBoxCP) that displays a list of records from a SQL table. When one of these is selected, another listbox (lBoxCB) is populated with data from a SQL table that is linked to the 1st table
I'm not sure what I'm doing wrong, but when you first click on a value in listbox1 (lBoxCP), it shows a list of values in listbox2 (lBoxCB) that are linked with the PREVIOUS value in listbox1 (lBoxCP), (basically the ID of the listbox item - 1) then, if you click the listbox1 value AGAIN, it shows the correct records
I'm using the lBoxCP_Selected IndexChanged() sub

My Code
Private Sub lBoxCP_Selected IndexChanged(By Val sender As System.Object, ByVal e As System.EventArg s) Handles lBoxCP.Selected IndexChange
'load cutblock lis
lBoxCB.DataSour ce = Nothin
Me.txtBox1.Data Bindings.Clear(
Me.txtBox2.Data Bindings.Clear(
Me.txtBox3.Data Bindings.Clear(

OleDbDataAdapte r3.SelectComman d.Parameters("I D_CUTTING_PERMI T").Value = txtCPID.Tex
DsCutBlock1.Cle ar(
OleDbDataAdapte r3.Fill(DsCutBl ock1
lBoxCB.DataSour ce = DsCutBlock
lBoxCB.DisplayM ember = "TDT_CUT_BLOCK. STR_BLOCK_NUMBE R

Me.txtBox1.Data Bindings.Add(Ne w System.Windows. Forms.Binding(" Text", Me.DsCutBlock1, "TDT_CUT_BLOCK. STR_BLOCK_NUMBE R")
Me.txtBox2.Data Bindings.Add(Ne w System.Windows. Forms.Binding(" Text", Me.DsCutBlock1, "TDT_CUT_BLOCK. NUM_AREA_APPROV ED")
Me.txtBox3.Data Bindings.Add(Ne w System.Windows. Forms.Binding(" Text", Me.DsCutBlock1, "TDT_CUT_BLOCK. STR_LOCATION")

End Su

Thanks
Ambe

Nov 20 '05 #7
Cor
Hi Amber,

Two things looks strange to me (I do not see all your code (do not send it,
because in a newsgroup that is mostly to much).

lBoxCB.DataSour ce = Nothing Why do you do this on this place and not later, does that not destroy your
data (I think not but it could be the next error)

OleDbDataAdapte r3.SelectComman d.Parameters("I D_CUTTING_PERMI T").Value =
txtCPID.Text

What is this Text I see it nowhere in your explanation (could misreaded it
of course).
(If you have linked it to lBoxCB it should go wrong when you set the
datasource of that to Nothing)

Maybe we are something further?

Cor
Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2247
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database that is used to connect to other databases and generate reports. below is sample code of how the database does the linking i hope i give you enough info to help me but if not let me know and i will give more. Sub txtShipDataFileSub() Dim...
1
2167
by: Josema | last post by:
Hi, My problem is the next one (in a windows application): - I have a class derived from collectionbase to fill with persons object (id, name) from database. - I have a ListBox wich datasource its the collectionbase above. I want to do: - I would like that when i click in a item of the listbox, deletes from database the values of this item, and from collection too. Then refresh the listbox with the collection modified.
3
6105
by: Stimp | last post by:
I have a listbox of values that I populate from a database. I want the user to be able to re-order the list (by first selecting an item and then clicking 'up' or 'down' buttons) and then save the list back to the database. First of all, I implemented the re-ordering through client-side javascript, which worked great (also it didn't require a postback every time an item was re-ordered). For testing purposes, I'm outputting the contents...
2
1610
by: Dennis | last post by:
I hoping you might be able to help me with a small problem. I have made an application that links a VB.NET program to a database. After many failed attempts and reading I can add, delete, navigate records and update the actual database. I have a simple database with two tables that form a car maintenance tracking program. One table holds the information on the car with a secondary table that holds service information. One of the fields in...
1
2084
by: lance2001 | last post by:
Hi, After viewing the entire Visual Basic 2005 Express Edition for Beginners video series, I have begun building a database driven application that will make use of listbox1 (multi-select) determining what shows up in listbox2 (multi_select), which determines listbox3, etc.... Each each listbox is populated from a different table in the same database. The databinding examples given in the video seem to leave no way for a
3
2391
by: Jay Ruyle | last post by:
I'm trying to figure out a way to list several items in a listbox and let the user select any number of items in the listbox. I have tried to code in the items as bitwise items but all it stores in the database is the top item in the listbox. How can I get the listbox to add all the bit values to be stored and also come out properly when viewed later? Example:
1
323
by: BerkshireGuy | last post by:
Ok - I have something I need help with and I am going to do my best to explain the siutation. I have a group of underwriters who can underwrite certain products. Some products they cannot underwriter. For the ones that they CAN underwrite - there are further restrictions - for instance - the amount of the policy applied for they can underwrite up to a certain amount. I build a form where a user can enter one or more product types (I...
1
4030
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which are not bound, I select from the bottom set and add to the top set which works fine, but now i decide to remove an item from the top set. when i tried to use a remove item code it worked fine, it did delete the item form the list but it added...
2
1182
by: aiswarya | last post by:
I've a table named student in my database.In it there are 7 columns .Now, in my form, when I click my table name, the name of columns should be displayed in one listbox ie in listbox1. Again, when I click one column name in listbox1,the corresponding attributes of that column should be displayed in listbox2. If the column selected is of varchar type, then the items populated in listbox should be in single quotes. If the column selected is...
0
10211
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.