Create "lookup link" in VB Express 2005 project

Ive created a VB Express 2005 project containing a Projects form and a Clients form, both of which are bound to SQL database tables.  Ive also created a foreign key link on ClientID (numeric-integer) so that there can be multiple projects assigned to any given client.  The basic functionality of these forms works OK.
My question is this:  I have a textbox in the Project form for ClientID and a textbox for the Client Name.
What is the best way to allow the user to select the client he wishes for the intended project and then display it immediately in the textbox before the rest of the form is filled out and saved?
GregorySingerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bob LearnedCommented:
If you want the user to be able to select from a list of clients, I would bind either a ListBox or a ComboBox to a datasource, with the client name as the DisplayMember and the client ID as the ValueMember.

Bob
0
GregorySingerAuthor Commented:
Thanks Bob,
When I add a combobox to the 'projects' form and bind to the 'clients' datasource, the box gets populated and I can select a client.  However, the selected ClientName and ClientID are not saved with the project record. In fact, if I advance from record to record, all have the same displayed client.
What am I omitting?

Thanks for your help.
0
Bob LearnedCommented:
>>...and bind to the 'clients' datasource

What is the datasource?

Bob
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

GregorySingerAuthor Commented:
As I stated, it is the 'clients' datasource. I'm somewhat new to this, but in thinking about it, once a 'client' is chosen from the combobox, something needs to bind the selected ClientID into the particular 'project' record so that the next time the project record is opened, the combobox can be forced to display the correct client. Am I wrong in my logic here?

Thanks- Greg
0
Bob LearnedCommented:
Can you show me a little code, because I don't quite understand what you are talking about?  I was looking to understand was your requirement and working environment is.  I don't even know if you are talking about ASP.NET web site, WinForms, SQL Server, Access, Oracle, ....

Bob
0
GregorySingerAuthor Commented:
Bob,
I'm using VB-2005 Express and SQL-Server 2005 Express.
Right now I'm in my office and do my program dabbling in the evenings.
If it is OK with you I will attach the db and vb files later this evening and send to you.
Actually, last evening I had some success in getting the 'resulting' CleintID value of the selected 'client' selected by the combobox to "write" into a 'CleintID' textbox which is itself bound to the 'project' datasource.  I was then using the ClientID 'field' to update the combobox upon re-opening the form or changing the record, but this didn't work exactly right.

Greg
0
Bob LearnedCommented:
Greg,

I just need more detailed insight into what you are trying to achieve, because I fail to see where you are having problems, and need my help.

Bob
0
GregorySingerAuthor Commented:
Bob,
I see that if I Zip the VB project and database that EE won't allow that kind of attachment.
Would you permit me to email it directly to you?

Greg
0
Bob LearnedCommented:
The process for attaching a file doesn't care about content, it only looks at the file extension.

Bob
0
GregorySingerAuthor Commented:
It does not allow zip files  ??

Greg
0
Bob LearnedCommented:
Rename the file, and add .txt and then attach the file, and I can download, and take the .txt off the file, and have a perfectly good .zip file.

Bob
0
GregorySingerAuthor Commented:
Great idea,

Didn't know if that would work.
See attached.
TNX

Greg
Project-zip.txt
0
Bob LearnedCommented:
I see on Form2, the PickClientComboBox client selection combo box.  I also see the ProjectsBindingSource and the ProjectsBindingNavigator on the form.  What I don't see is where you bind the controls in the "General Project Data" group to the binding source.

Bob
0
Bob LearnedCommented:
Reference:

Binding Data to WinForms Controls in VB.NET 2.0
http://www.codeguru.com/csharp/csharp/cs_syntax/controls/article.php/c10815/

Bob
0
GregorySingerAuthor Commented:
In the IDE window, if you look at the properties box of each of the objects in the General Project Data group, you will see that the text is bound to the PorjectBindingDataSource.
This is not th issue, this works.
If you run the form, the idea is that when a new project is started, the user needs to select a client.
Currently, I'm trying the combobox", PickClientCombobox" as you see.
When a client is picked, an event is fired that sets the ClientID box to the value of the Client.
This works.
However, after picking the client, if you advance with the forward/reverse navigate buttons, at first the displayed name of the client in the ClientNameTextBox matches the ClientID. Then when you go reverse, if no longer matches the ClientID and I can't figure out why.
Maybe there is a better way to do this?

Greg
0
Bob LearnedCommented:
Greg,

Does "when a new project is started" mean that you click on the "Add new" button on the toolstrip?

Bob
0
GregorySingerAuthor Commented:
Bob,

Yes.  In the intervening days, I found that there is apparently a difference between the 'data bound items'  that can be assigned from the little pop-up arrow flag (don't know the exact name) and the data bindings in the properties window.  I apparently had made assignments to both, and the resulting conflict did not allow the PickClientComboBox to work and display the proper information at all times.
Now that I only have the data bound items assigned directly to the combox control, it works the way it should.  
You've been helpful and patient; if you have no further comments on this I will award the full points to you.

Thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.