473,545 Members | 2,688 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to assign values in combo box

40 New Member
Hi,
I am new to access so please bear my question.
In a form, I have a combo box(combo1) that store values in field(remarks1) in a table.The values in combo box are:
SL
ST
DI
SL + ST
SL + DI
These all values are being saved in remarks1 quiet easily.
I have more fields in the table:
SL1
ST1
DT1
SLST1
SLDI1
I want when I selet SL from combo1 it saves SL in remarks1 and save "1" as well in SL1 field.I want to have same result with all five combo1 values
Please assist me.
Nov 1 '14 #1
3 1500
jimatqsi
1,273 Recognized Expert Top Contributor
Combo boxes have an After Update event. In the After Update event of combo1 you can put some VBA code to update any other fields you want. You'll put something like
Expand|Select|Wrap|Line Numbers
  1. me.SL1 = 1
if it's a numeric 1 or
Expand|Select|Wrap|Line Numbers
  1. me.SL1="1"
if it's an alpha.
Of course you'll have to put that in a select case or if/then mechanism to make sure you're setting the right value in SL1. Like this, for instance:
Expand|Select|Wrap|Line Numbers
  1. Select case me.combo1
  2.    case "SL"
  3.         me.SL1=1
  4.    case "ST"
  5.         me.SL1=???
  6.    case "DI"
  7.    case "SL+ST"
  8.    case "SL+DI"
  9. end select
  10.  
I'm not exactly sure what you mean by "I want to have same result with all five combo1 values" but if you get the above I suspect you can expand on that easily.

You might consider making combo1 a 2-column combo box. You could have the 2nd column invisible (columnwidths=1 ;0; assuming width=1 for column 1 is okay). In the second column you could have the value that matches the first column. In that case, your VBA code could be
Expand|Select|Wrap|Line Numbers
  1. me.SL1=me.combo1.column(1)
Column(1) refers to the 2nd column, not the first.

Hope that helps.
Nov 1 '14 #2
irslan rafique
40 New Member
Thanks a lot for putting me on right track.
I am using this code now:
Expand|Select|Wrap|Line Numbers
  1. Select Case Me.Combo1043
  2.    Case "Staging"
  3.         Me.Staging1 = "1"
  4.    Case "Diversion"
  5.         Me.Diversion1 = "1"
  6.  
  7. End Select
But one problem.
If i select Staging and suppose the actual value is diversion so I will select diversion in the combo box so in result it passes "1" in both related fields (Staging1 & Diversion1)
Need your more help please.
Nov 1 '14 #3
jforbes
1,107 Recognized Expert Top Contributor
I'm not exactly sure what you are attempting to do, but I'm guessing that you want all the fields set to nothing except the fields you are setting to one. If this is true, you can use the following:
Expand|Select|Wrap|Line Numbers
  1. Select Case Me.Combo1043
  2.     Case "Staging"
  3.          Me.Staging1 = "1"
  4.          Me.Diversion1 = "" 
  5.     Case "Diversion"
  6.          Me.Staging1 = ""
  7.          Me.Diversion1 = "1" 
  8.  End Select
If you are looking to put a "0" in that field instead, use:
Expand|Select|Wrap|Line Numbers
  1. Select Case Me.Combo1043
  2.     Case "Staging"
  3.          Me.Staging1 = "1"
  4.          Me.Diversion1 = "0" 
  5.     Case "Diversion"
  6.          Me.Staging1 = "0"
  7.          Me.Diversion1 = "1" 
  8.  End Select
Nov 3 '14 #4

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

Similar topics

6
1725
by: Buddy Ackerman | last post by:
I created a simple class: Public Class MyTestClass Public Test() As String End Class I tried to assign some values to the array Test() and display them like this:
2
1833
by: MLH | last post by:
Gentlemen: I have declared an array Dim MyTables(14) AS Long Now I want to assign values for MyTables(0) - MyTables(14) equal to the number of records in each table. Catch, I want the code to identify only those tables beginning with the letters "JA". Is this possible? Or, should I break down and manually type in all the table names?
7
21927
by: Paul via AccessMonster.com | last post by:
I have a report with some Unbound text boxes. I want to shows the values in these text boxes from my VBA code. How can I assign the valuse thru code ? Pls help me. -- Message posted via http://www.accessmonster.com
2
7204
by: gjtired | last post by:
Currently I am retrieving values from a dataset and assigning the values to a textbox. I then assign the value from the textbox to a variable. I don't need the values in the textbox at all. I'm sure there is an easier way than I'm doing it. Any suggestions or help would be appreciated. Below is a snippet of code to show what I'm currently...
2
2975
by: dBNovice | last post by:
Hi all! I have 3 separate forms: Tasks, Subtasks, and Elements. All 3 is related by TaskId and Subtasks and Elements are related by SubtaskID. In the DB after I add a task, I want to be able to add one or more subtasks and then one or more elements. I need the subtasks and elements to be have the same taskid as the task; also I want the...
6
2252
by: david | last post by:
I try to use "for" loop to retrieve and assign values in web form. The code is in the following. But it can not be compiled. What I want to do is: txtQ1.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q1") txtQ2.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q2") ..... txtQ10.Text = ds.Tables("mmsSpecRecord").Rows(0)("Q10") ------code ------- Dim...
8
1842
by: fanoftvb | last post by:
hi, is it possible to assign values to button? I will not need to enter any values and when i click on the button, the values on the datagrid and database will automatically change. Is there anyway to do it? Thanx in advance.
1
2701
by: NewHeights | last post by:
Excel 2007- I have a survey that uses radio buttons (3 choices each answer) to select the answer.? My trouble starts with assigning values to the answers (Answer 1 is 0, Answer 2 is 1, Answer 3 is 2), so that at the end of each section the total can be automatically calculated to eventually have a final total of all the sections. My Questions...
1
1061
by: gourik | last post by:
Can we assign values for symbolic constants in enumerations where value assigned for Is it possible in c#? If not then please give me the reason? enum student { UG=10; PG=100; }
0
7689
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7456
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6022
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3490
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1919
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1044
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
743
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.