473,387 Members | 1,463 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,387 software developers and data experts.

Code not working to enable control based on input into another control

Based on other bits of code I've found for this issue, I have this code on the After Update event of the first control (combo box POI in which "Hail" is in the set) but regardless of the input with this code, there is no change in control "Measurements". Please help show me what I'm missing.

Expand|Select|Wrap|Line Numbers
  1. Private Sub POI_AfterUpdate()
  2. If (Me.POI = "Hail") Then
  3.  Me.Measurements.Enabled = False
  4. Else
  5. Me.Measurements.Enabled = True
  6. End If
  7. End Sub
Thanks!
Aug 15 '12 #1

✓ answered by zmbd

Typically this is because the bound column of the combobox does not have the value you've tested for...

I would suspect that the combobox has 2 or more columns.
The first column has the primary key such as 1, 2, 3...
The second column has the text such as Hello; Hail; Aloha... which is what the user sees.
The bound column is 1 for the control (set in the properties)

So in my example.. "2 = Hail" there are a couple of ways to fix this... so try this code (change the number to match your data)

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub POI_AfterUpdate()
  5. Dim z_lng_cbobox_poi As Long
  6. '
  7. 'Need an error trap?
  8. '
  9. 'Get the value from the form control
  10. z_lng_cbobox_poi = Me.POI.Value
  11. '
  12. 'check to see what the value was and
  13. 'enable if the user selected the "Hail" entry
  14. If (z_lng_cbobox_poi = 2) Then     '<<<Note the change
  15.  Me.Measurements.Enabled = False  
  16. Else
  17. Me.Measurements.Enabled = True
  18. End If
  19. '
  20. 'error trap code would go here
  21. End Sub

1 1633
zmbd
5,501 Expert Mod 4TB
Typically this is because the bound column of the combobox does not have the value you've tested for...

I would suspect that the combobox has 2 or more columns.
The first column has the primary key such as 1, 2, 3...
The second column has the text such as Hello; Hail; Aloha... which is what the user sees.
The bound column is 1 for the control (set in the properties)

So in my example.. "2 = Hail" there are a couple of ways to fix this... so try this code (change the number to match your data)

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub POI_AfterUpdate()
  5. Dim z_lng_cbobox_poi As Long
  6. '
  7. 'Need an error trap?
  8. '
  9. 'Get the value from the form control
  10. z_lng_cbobox_poi = Me.POI.Value
  11. '
  12. 'check to see what the value was and
  13. 'enable if the user selected the "Hail" entry
  14. If (z_lng_cbobox_poi = 2) Then     '<<<Note the change
  15.  Me.Measurements.Enabled = False  
  16. Else
  17. Me.Measurements.Enabled = True
  18. End If
  19. '
  20. 'error trap code would go here
  21. End Sub
Aug 15 '12 #2

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

Similar topics

3
by: william | last post by:
Hi, I have a dropdownlist control and a few textbox on my web form. How can I update those textbox content when user select item from dropdownlist control? I really want to do this on client...
2
by: thomasamillergoogle | last post by:
I have a page that has hundreds of textboxes added dynamically by writing out "<input type = text name=ctl_99>". In other words, these are NOT asp.net web controls. I want to enable viewstate...
0
by: scotprince | last post by:
Hi, I am hoping someone here can help. I have one custom control called "MyButton". On another custom control (CC2) I dynamically create a table and add the "MyButton" control to a cell or...
0
by: alwayssmiling | last post by:
Hi, In my application, In the main form tab control is there. For this im adding a tabpage which contains a user control, this usercontrol contains many windows controls and other userdefined...
1
by: poops2468 | last post by:
I have a form with a lot of text boxes and an equal number of check boxes. I want the check box to be disabled if the text in the text box is a certain value. I'm still a VB noob, so forgive me if my...
5
by: EORTIZ | last post by:
I want to know how I can enable (activate) a control in a form if another control is filled. For example, I have a questionnaire and I want to skip questions depending on the answer of a previous...
4
WyvsEyeView
by: WyvsEyeView | last post by:
I am doing the very standard thing of filtering the contents of one combo box based on another combo box. I've done it many times, but always on a main form. Now I'm trying to do it on a datasheet...
0
by: jholland13 | last post by:
Hi, I manage a Access 07 dbase as part of my job. I am not very good at programming, no formal training. Most things it does by code I found snippets and modified them. Something I want to do is...
1
by: vikram rawat | last post by:
I want to ask solution of one problem that is: - supppose there is two control in a panel, whenever i drag the one control near the another control in a panel, then it show a dot imag near that...
2
repath
by: repath | last post by:
Dear All: Issue: I used a tab control with 3 tabs, named personal details, academic record, Extra curricular activities (ECA): Each tab has respective controls like option buttons with in a...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.