[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Create "lookup link" in VB Express 2005 project

Posted on 2008-02-05
17
Medium Priority
?
257 Views
Last Modified: 2011-10-19
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?
0
Comment
Question by:GregorySinger
  • 9
  • 8
17 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20822873
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
 

Author Comment

by:GregorySinger
ID: 20837526
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20840857
>>...and bind to the 'clients' datasource

What is the datasource?

Bob
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:GregorySinger
ID: 20847098
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20847482
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
 

Author Comment

by:GregorySinger
ID: 20849513
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20852557
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
 

Author Comment

by:GregorySinger
ID: 20857737
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20866549
The process for attaching a file doesn't care about content, it only looks at the file extension.

Bob
0
 

Author Comment

by:GregorySinger
ID: 20873767
It does not allow zip files  ??

Greg
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20874838
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
 

Author Comment

by:GregorySinger
ID: 20880725
Great idea,

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

Greg
Project-zip.txt
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20884406
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
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20884414
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
 

Author Comment

by:GregorySinger
ID: 20892263
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
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 2000 total points
ID: 20932675
Greg,

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

Bob
0
 

Accepted Solution

by:
GregorySinger earned 0 total points
ID: 20943847
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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

590 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