Put a variable in a textbox/combobox
Solved
ice_dj03
Posted messages
12
Status
Member
-
kadeh Posted messages 341 Status Member -
kadeh Posted messages 341 Status Member -
Bonjour,
Here is my new problem.
I have a userform that asks for information about a client, to keep it simple: last name, first name, address, and phone number.
When I validate this userform, it copies the information to a line in Excel (always the same, line 4), sorts my client file by last name, and then inserts a blank line for the next entry.
So far, I think I can manage, but the issue is that I would like to create a userform that, before reaching my client information request form, offers to consult the client file to see if the contact already exists.
Once again, I think I can achieve this by opening a userform that asks which line corresponds to the concerned contact.
The crucial moment arrives when I want that, after selecting the client, knowing that each piece of information is in a variable,
the last name is in VarNom
the first name in VarPrenom...
I would like these details to be reported in the information form... (sorry if I’m not very clear, I’m doing my best) that is to say, where I normally have an EMPTY textbox for the last name, I instead have a textbox that takes the value of the content of VarNom...
I haven't typed any of the codes yet that I think I will manage, I'm working on it but I'm already thinking about the future hassle of this transition, if anyone has a brilliant idea ;) it would be gladly welcome!
Thank you in advance!
Here is my new problem.
I have a userform that asks for information about a client, to keep it simple: last name, first name, address, and phone number.
When I validate this userform, it copies the information to a line in Excel (always the same, line 4), sorts my client file by last name, and then inserts a blank line for the next entry.
So far, I think I can manage, but the issue is that I would like to create a userform that, before reaching my client information request form, offers to consult the client file to see if the contact already exists.
Once again, I think I can achieve this by opening a userform that asks which line corresponds to the concerned contact.
The crucial moment arrives when I want that, after selecting the client, knowing that each piece of information is in a variable,
the last name is in VarNom
the first name in VarPrenom...
I would like these details to be reported in the information form... (sorry if I’m not very clear, I’m doing my best) that is to say, where I normally have an EMPTY textbox for the last name, I instead have a textbox that takes the value of the content of VarNom...
I haven't typed any of the codes yet that I think I will manage, I'm working on it but I'm already thinking about the future hassle of this transition, if anyone has a brilliant idea ;) it would be gladly welcome!
Thank you in advance!
3 answers
Hello,
several solutions are at your disposal
- you can create a "search" button in your user form, so by typing the name or code in a textbox, you click on the "search" button and all the client information is displayed in your user form.
- or you can add to your macro a piece of code that, before validating the client information, checks if the client number or name already exists in your client list, and if it exists, cancels the validation and selects the row containing the information of that client
- you can also create an update button on your user form for updating client data
......
choose what suits you and I am ready to help you
several solutions are at your disposal
- you can create a "search" button in your user form, so by typing the name or code in a textbox, you click on the "search" button and all the client information is displayed in your user form.
- or you can add to your macro a piece of code that, before validating the client information, checks if the client number or name already exists in your client list, and if it exists, cancels the validation and selects the row containing the information of that client
- you can also create an update button on your user form for updating client data
......
choose what suits you and I am ready to help you
RE,
I understand the principle, there’s no problem on that side.
My issue is doing something like
USFInfoClient.TextBox1 = 'the content of my variable VarNom
I know that the inverse works
VarNom = USFInfoClient.TextBox1
And what I type is assigned to my variable, but in the first case, is it possible and how??
Maybe
USFInfoClient.TextBox1 = &VarNom '???
Thanks ;)
I understand the principle, there’s no problem on that side.
My issue is doing something like
USFInfoClient.TextBox1 = 'the content of my variable VarNom
I know that the inverse works
VarNom = USFInfoClient.TextBox1
And what I type is assigned to my variable, but in the first case, is it possible and how??
Maybe
USFInfoClient.TextBox1 = &VarNom '???
Thanks ;)
If I understood you correctly, you want the USFInfoClient.TextBox1 to automatically take the value of "VarNom" when your userform is displayed?
If that is what you want, you should do this at the beginning of the macro that calls your userform.
USFInfoClient.Show 0
USFInfoClient.TextBox1.Value = Sheets("the sheet where VarNom is located").Range("cell").Value
If that's not what you want, please explain a bit more about what you need.
@+
If that is what you want, you should do this at the beginning of the macro that calls your userform.
USFInfoClient.Show 0
USFInfoClient.TextBox1.Value = Sheets("the sheet where VarNom is located").Range("cell").Value
If that's not what you want, please explain a bit more about what you need.
@+
Thank you, this manipulation should hold up, thanks again for your quickness.
I have another question, I'm not used to forums, do I need to create a new post?
I have another question, I'm not used to forums, do I need to create a new post?
If you want to create another topic, you should create a new post with a new title so that others can help you.
The title of the message must correspond well to the discussion; otherwise, we have to search through the different messages in the discussion to see what you are looking for.
So please post a new topic.
@+
The title of the message must correspond well to the discussion; otherwise, we have to search through the different messages in the discussion to see what you are looking for.
So please post a new topic.
@+