By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,489 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,489 IT Pros & Developers. It's quick & easy.

Code to Set Control Source for Bound ComboBox

P: 23
hello every body
I want to know that is there a way to assign multiple InputMasks to a combo box. I have two combo boxes on same form. value in 1st combo box come from a query and may contain words like "Cap", "Tab", "Inj", "Ampules" etc. I want that 2nd combo box should have above mentioned values i.e "Cap", "Tab", "Inj", "Ampules" at the end of its value.
suppose 1st combo box have value "Cap Indocid" and when I select 2 from 2nd combo box, it should display it as "2 Cap" instead of "2" only and if 1st combo box have "Tab Indocid", 2nd combo box should display it as "2 Tab"..
Jan 1 '12 #1
Share this Question
Share on Google+
3 Replies


NeoPa
Expert Mod 15k+
P: 31,709
This has absolutely nothing to do with Input Masks.

To get something like this to work you'd need to :
  1. Decide exactly what you want to happen (Your explanation is so short of important detail as to be almost useless). We know almost nothing about the second ComboBox except that it is a ComboBox. Is the string to be added a single word in all cases? Should it be the whole of the value of the first ComboBox? Without knowing what you want to do it is impossible to explain how to do it.
  2. Update the Control Source property for the second ComboBox to add the current value of the first ComboBox (or the first word or whatever you decide) to the end after a space. We have almost no information to work with so I cannot suggest anything of more detail at this stage.
  3. Creat an AfterUpdate event procedure for your first ComboBox which calls a .Refresh of your second ComboBox. This will ensure that the value of the first ComboBox is always reflected in the second.
Jan 2 '12 #2

P: 23
My first combo box is a bound combo box that populates its value from a query DrugList. It displays complete name of drug as "Cap Amoxil 250 mg" In "Cap Amoxil 250 mg" 'Cap' is the form of drug, 'Amoxil' is the Trade Name and '250 mg' is the strength. My second combo box has a table as RowSourse that have numeric values 2 through 20
I want that first word in the 1st combo box should automatically be added to the value selected in 2nd combo box. I want that in above example if I select 2, it should display as '2 Cap'. suppose Drug form in 1st combo box be 'Tab' and complete value 'Tab Amoxil 250 mg', then on selecting 2 from 2nd combo box , the value displayed in 2nd combo box should be '2 Tab'. Can this all be done by formatting multiple InputMasks to 2nd combo box..???. Hope now you understand my question.
Jan 2 '12 #3

NeoPa
Expert Mod 15k+
P: 31,709
Yousaf Shah:
Can this all be done by formatting multiple InputMasks to 2nd combo box..???.
No. I've already explained that quite fully even though your question didn't make sense. No. Input Masks have nothing to do with what you are asking about. I have already explained what you need.
Yousaf Shah:
Hope now you understand my question.
I understand that part of your question you actually included. What I didn't understand was that part you didn't include in the question.

Now I understand that, for some inexplicable reason, you have chosen to mix up multiple fields of data into the same string values (in your first ComboBox). You have a choice here where you either discover how much more complicated this makes your task of separating out the required element for use later, or you keep the three values in your first ComboBox in three separate columns where you may choose to show all three, but only the relevant one is returned in the value (Bound Column).
Jan 2 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.