473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to assign values in combo box

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 1491
jimatqsi
1,271 Expert 1GB
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
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 Expert 1GB
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
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
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...
7
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...
2
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...
2
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...
6
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 =...
8
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...
1
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...
1
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.