GregorySinger
asked on
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?
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?
ASKER
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.
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.
>>...and bind to the 'clients' datasource
What is the datasource?
Bob
What is the datasource?
Bob
ASKER
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
Thanks- Greg
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
Bob
ASKER
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
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
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
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
ASKER
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
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
The process for attaching a file doesn't care about content, it only looks at the file extension.
Bob
Bob
ASKER
It does not allow zip files ??
Greg
Greg
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
Bob
ASKER
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
Bob
Reference:
Binding Data to WinForms Controls in VB.NET 2.0
http://www.codeguru.com/csharp/csharp/cs_syntax/controls/article.php/c10815/
Bob
Binding Data to WinForms Controls in VB.NET 2.0
http://www.codeguru.com/csharp/csharp/cs_syntax/controls/article.php/c10815/
Bob
ASKER
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
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
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Bob