If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Textbox dependent on Listbox values
Can someone help me write a code that basically says this:
If [MyTxtbox] does not equal any value in [MyLstBox] Then Msgbox "That value does not exist. Please try another value." I need to have both the Listbox and the Textbox on my form, but I can't figure out a code that will check the new value of the textbox if it's been changed after the first msgbox. |
#2
|
|||
|
|||
Textbox dependent on Listbox values
You are approaching this wrong. Never allow a user to enter a value that must
then be checked against a fixed set of values. Always force the user to select the value from the fixed set in the first place. A classic exampe of this is what you gave; another example would be a date. Dates should never be entered but always picked from a calendar. -Dorian "mb" wrote: Can someone help me write a code that basically says this: If [MyTxtbox] does not equal any value in [MyLstBox] Then Msgbox "That value does not exist. Please try another value." I need to have both the Listbox and the Textbox on my form, but I can't figure out a code that will check the new value of the textbox if it's been changed after the first msgbox. |
#3
|
|||
|
|||
Textbox dependent on Listbox values
Ok. I've changed the listbox to a combobox to do what you've suggested.
Now, is there a way to do either (or all) of the following: 1. Remove the drop down arrow to force users to type the text instead of just scrolling through and selecting from the long list? 2. Customize my own error message if the user selects a value that's not in the list? Thanks for your help. "mscertified" wrote: You are approaching this wrong. Never allow a user to enter a value that must then be checked against a fixed set of values. Always force the user to select the value from the fixed set in the first place. A classic exampe of this is what you gave; another example would be a date. Dates should never be entered but always picked from a calendar. -Dorian "mb" wrote: Can someone help me write a code that basically says this: If [MyTxtbox] does not equal any value in [MyLstBox] Then Msgbox "That value does not exist. Please try another value." I need to have both the Listbox and the Textbox on my form, but I can't figure out a code that will check the new value of the textbox if it's been changed after the first msgbox. |
#4
|
|||
|
|||
Textbox dependent on Listbox values
I'm inclined to agree in general with your comment about the OP's specific
question, but I disagree strongly with your "never" and "always" assertions about populating a date field. In a web page or other situation where there will be users of all levels and there is considerable risk of a data being entered incorrectly, I can see your point, but I would not ask a competent user who can enter the date in a second or two to scroll through a calendar control (particularly for a date several months or years removed from the current one) or pick year/month/day from separate drop-down lists. "mscertified" wrote in message ... You are approaching this wrong. Never allow a user to enter a value that must then be checked against a fixed set of values. Always force the user to select the value from the fixed set in the first place. A classic exampe of this is what you gave; another example would be a date. Dates should never be entered but always picked from a calendar. -Dorian "mb" wrote: Can someone help me write a code that basically says this: If [MyTxtbox] does not equal any value in [MyLstBox] Then Msgbox "That value does not exist. Please try another value." I need to have both the Listbox and the Textbox on my form, but I can't figure out a code that will check the new value of the textbox if it's been changed after the first msgbox. |
#5
|
|||
|
|||
Textbox dependent on Listbox values
Maybe you could elaborate a little on what exactly you are trying to
do. On the surface it would seem to make no sense to present the user with a list of choices, but then not allow them to choose from the list. -- _________ Sean Bailey "mb" wrote: Ok. I've changed the listbox to a combobox to do what you've suggested. Now, is there a way to do either (or all) of the following: 1. Remove the drop down arrow to force users to type the text instead of just scrolling through and selecting from the long list? 2. Customize my own error message if the user selects a value that's not in the list? Thanks for your help. "mscertified" wrote: You are approaching this wrong. Never allow a user to enter a value that must then be checked against a fixed set of values. Always force the user to select the value from the fixed set in the first place. A classic exampe of this is what you gave; another example would be a date. Dates should never be entered but always picked from a calendar. -Dorian "mb" wrote: Can someone help me write a code that basically says this: If [MyTxtbox] does not equal any value in [MyLstBox] Then Msgbox "That value does not exist. Please try another value." I need to have both the Listbox and the Textbox on my form, but I can't figure out a code that will check the new value of the textbox if it's been changed after the first msgbox. |
#6
|
|||
|
|||
Textbox dependent on Listbox values
Sorry for the confusion. I was able to figure out the custom error message.
What happened next is I resized the box and the arrow was no longer the same height as the box itself (it's only half as tall), so I was wondering if I could possibly eliminate the arrow altogether (maybe set it's height to 0"). Then the drop down list would only appear when the user starts typing. "Beetle" wrote: Maybe you could elaborate a little on what exactly you are trying to do. On the surface it would seem to make no sense to present the user with a list of choices, but then not allow them to choose from the list. -- _________ Sean Bailey "mb" wrote: Ok. I've changed the listbox to a combobox to do what you've suggested. Now, is there a way to do either (or all) of the following: 1. Remove the drop down arrow to force users to type the text instead of just scrolling through and selecting from the long list? 2. Customize my own error message if the user selects a value that's not in the list? Thanks for your help. "mscertified" wrote: You are approaching this wrong. Never allow a user to enter a value that must then be checked against a fixed set of values. Always force the user to select the value from the fixed set in the first place. A classic exampe of this is what you gave; another example would be a date. Dates should never be entered but always picked from a calendar. -Dorian "mb" wrote: Can someone help me write a code that basically says this: If [MyTxtbox] does not equal any value in [MyLstBox] Then Msgbox "That value does not exist. Please try another value." I need to have both the Listbox and the Textbox on my form, but I can't figure out a code that will check the new value of the textbox if it's been changed after the first msgbox. |
Thread Tools | |
Display Modes | |
|
|