473,782 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Capture Unbound Form Control's Value

Hello. I'm trying to capture a controls value: a dropdown box with two
selections (either "Red" or "Blue") keeps returning the value "Red" even if
"Blue" is selected?
Oct 5 '07 #1
13 1512
On Oct 5, 12:36 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Hello. I'm trying to capture a controls value: a dropdown box with two
selections (either "Red" or "Blue") keeps returning the value "Red" even if
"Blue" is selected?
Donald, which property are you using to access the value? Could you
post you code as well?

Oct 5 '07 #2
Say I have a control "CboColor" on a form with the "ITEMS" collection set to
list 'Red' and 'Blue' and the "TEXT" value set to 'Red'. I'm trying to get
the value of the control via code as such:

Dim strCboColorVal
strCboColorVal = Me.CboColor.Tex t()

Then to check if it's working:

Debug.Print(str CboColorVal)

And the value 'Red' occurs even if 'Blue' is selected in the dropdown box.

"Charlie Brown" wrote:
On Oct 5, 12:36 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Hello. I'm trying to capture a controls value: a dropdown box with two
selections (either "Red" or "Blue") keeps returning the value "Red" even if
"Blue" is selected?

Donald, which property are you using to access the value? Could you
post you code as well?

Oct 5 '07 #3
On Oct 5, 1:42 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Say I have a control "CboColor" on a form with the "ITEMS" collection set to
list 'Red' and 'Blue' and the "TEXT" value set to 'Red'. I'm trying to get
the value of the control via code as such:

Dim strCboColorVal
strCboColorVal = Me.CboColor.Tex t()

Then to check if it's working:

Debug.Print(str CboColorVal)

And the value 'Red' occurs even if 'Blue' is selected in the dropdown box.

"Charlie Brown" wrote:
On Oct 5, 12:36 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Hello. I'm trying to capture a controls value: a dropdown box with two
selections (either "Red" or "Blue") keeps returning the value "Red" even if
"Blue" is selected?
Donald, which property are you using to access the value? Could you
post you code as well?- Hide quoted text -

- Show quoted text -
Try using...

strCboColorVal = Me.CboColor.Sel ectedItem.Text

Oct 5 '07 #4
..Text is not available for .SelectedItem. I tried .ToString and got same
unwanted result.

"Charlie Brown" wrote:
On Oct 5, 1:42 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Say I have a control "CboColor" on a form with the "ITEMS" collection set to
list 'Red' and 'Blue' and the "TEXT" value set to 'Red'. I'm trying to get
the value of the control via code as such:

Dim strCboColorVal
strCboColorVal = Me.CboColor.Tex t()

Then to check if it's working:

Debug.Print(str CboColorVal)

And the value 'Red' occurs even if 'Blue' is selected in the dropdown box.

"Charlie Brown" wrote:
On Oct 5, 12:36 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Hello. I'm trying to capture a controls value: a dropdown box with two
selections (either "Red" or "Blue") keeps returning the value "Red" even if
"Blue" is selected?
Donald, which property are you using to access the value? Could you
post you code as well?- Hide quoted text -
- Show quoted text -

Try using...

strCboColorVal = Me.CboColor.Sel ectedItem.Text

Oct 5 '07 #5
On Oct 5, 2:21 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
.Text is not available for .SelectedItem. I tried .ToString and got same
unwanted result.

"Charlie Brown" wrote:
On Oct 5, 1:42 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Say I have a control "CboColor" on a form with the "ITEMS" collection set to
list 'Red' and 'Blue' and the "TEXT" value set to 'Red'. I'm trying to get
the value of the control via code as such:
Dim strCboColorVal
strCboColorVal = Me.CboColor.Tex t()
Then to check if it's working:
Debug.Print(str CboColorVal)
And the value 'Red' occurs even if 'Blue' is selected in the dropdown box.
"Charlie Brown" wrote:
On Oct 5, 12:36 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Hello. I'm trying to capture a controls value: a dropdown box with two
selections (either "Red" or "Blue") keeps returning the value "Red" even if
"Blue" is selected?
Donald, which property are you using to access the value? Could you
post you code as well?- Hide quoted text -
- Show quoted text -
Try using...
strCboColorVal = Me.CboColor.Sel ectedItem.Text- Hide quoted text -

- Show quoted text -
Sorry, I mistyped on that last one...

strCboColorVal = Me.CboColor.Sel ectedText

Oct 5 '07 #6
That's not working either. Here's a part of what I'm working with:

If DUEDATE < Now() And
frmMain.CboOdue Color.Text = "Red" Then
Debug.Print(frm Main.CboOdueCol or.Text)
With oSheet.Range("A " & iRow, "K" &
iRow)
.Font.ColorInde x = 3
Debug.Print("Co lor Set to RED")
End With
ElseIf DUEDATE < Now() And
frmMain.CboOdue Color.Text = "Blue" Then
Debug.Print(frm Main.CboOdueCol or.Text)
With oSheet.Range("A " & iRow, "K" &
iRow)
.Font.ColorInde x = 5
Debug.Print("Co lor Set to BLUE")
End With
End If
"Charlie Brown" wrote:
On Oct 5, 2:21 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
.Text is not available for .SelectedItem. I tried .ToString and got same
unwanted result.

"Charlie Brown" wrote:
On Oct 5, 1:42 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Say I have a control "CboColor" on a form with the "ITEMS" collection set to
list 'Red' and 'Blue' and the "TEXT" value set to 'Red'. I'm trying to get
the value of the control via code as such:
Dim strCboColorVal
strCboColorVal = Me.CboColor.Tex t()
Then to check if it's working:
Debug.Print(str CboColorVal)
And the value 'Red' occurs even if 'Blue' is selected in the dropdown box.
"Charlie Brown" wrote:
On Oct 5, 12:36 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Hello. I'm trying to capture a controls value: a dropdown box with two
selections (either "Red" or "Blue") keeps returning the value "Red" even if
"Blue" is selected?
Donald, which property are you using to access the value? Could you
post you code as well?- Hide quoted text -
- Show quoted text -
Try using...
strCboColorVal = Me.CboColor.Sel ectedItem.Text- Hide quoted text -
- Show quoted text -

Sorry, I mistyped on that last one...

strCboColorVal = Me.CboColor.Sel ectedText

Oct 5 '07 #7
On Oct 5, 5:13 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
That's not working either. Here's a part of what I'm working with:

If DUEDATE < Now() And
frmMain.CboOdue Color.Text = "Red" Then
Debug.Print(frm Main.CboOdueCol or.Text)
With oSheet.Range("A " & iRow, "K" &
iRow)
.Font.ColorInde x = 3
Debug.Print("Co lor Set to RED")
End With
ElseIf DUEDATE < Now() And
frmMain.CboOdue Color.Text = "Blue" Then
Debug.Print(frm Main.CboOdueCol or.Text)
With oSheet.Range("A " & iRow, "K" &
iRow)
.Font.ColorInde x = 5
Debug.Print("Co lor Set to BLUE")
End With
End If

"Charlie Brown" wrote:
On Oct 5, 2:21 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
.Text is not available for .SelectedItem. I tried .ToString and got same
unwanted result.
"Charlie Brown" wrote:
On Oct 5, 1:42 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Say I have a control "CboColor" on a form with the "ITEMS" collection set to
list 'Red' and 'Blue' and the "TEXT" value set to 'Red'. I'm trying to get
the value of the control via code as such:
Dim strCboColorVal
strCboColorVal = Me.CboColor.Tex t()
Then to check if it's working:
Debug.Print(str CboColorVal)
And the value 'Red' occurs even if 'Blue' is selected in the dropdown box.
"Charlie Brown" wrote:
On Oct 5, 12:36 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Hello. I'm trying to capture a controls value: a dropdown box with two
selections (either "Red" or "Blue") keeps returning the value "Red" even if
"Blue" is selected?
Donald, which property are you using to access the value? Could you
post you code as well?- Hide quoted text -
- Show quoted text -
Try using...
strCboColorVal = Me.CboColor.Sel ectedItem.Text- Hide quoted text -
- Show quoted text -
Sorry, I mistyped on that last one...
strCboColorVal = Me.CboColor.Sel ectedText- Hide quoted text -

- Show quoted text -
Assuming you used the designer property dialog to set the Items
collection by typing Red on the first line, and Blue on the second
line, the follwing code will produce th correct result...

If frmMain.cboOdue Color.SelectedI tem.ToString = "Red" Then

....

End If

will give you the result you are looking for.

Oct 6 '07 #8
Still not working. I'm using this code from a separate class to catch/use
the values of the controls but they are only returning the values they were
set to at design time. How to return current values?

Dim strFontSize
strFontSize = frmMain.NumFont Size.Value.ToSt ring
If strFontSize = 10 Then
Debug.Print(str FontSize)
ElseIf strFontSize = 17 Then
Debug.Print(str FontSize)
End If
Dim ODueFontColor, ODueFontColorVa l
ODueFontColor = frmMain.CboOdue Color.SelectedI tem.ToString
If ODueFontColor = "Red" Then
ODueFontColorVa l = 3
Debug.Print(ODu eFontColorVal)
ElseIf ODueFontColor = "Blue" Then
ODueFontColorVa l = 5
Debug.Print(ODu eFontColorVal)
End If
"Charlie Brown" wrote:
On Oct 5, 5:13 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
That's not working either. Here's a part of what I'm working with:

If DUEDATE < Now() And
frmMain.CboOdue Color.Text = "Red" Then
Debug.Print(frm Main.CboOdueCol or.Text)
With oSheet.Range("A " & iRow, "K" &
iRow)
.Font.ColorInde x = 3
Debug.Print("Co lor Set to RED")
End With
ElseIf DUEDATE < Now() And
frmMain.CboOdue Color.Text = "Blue" Then
Debug.Print(frm Main.CboOdueCol or.Text)
With oSheet.Range("A " & iRow, "K" &
iRow)
.Font.ColorInde x = 5
Debug.Print("Co lor Set to BLUE")
End With
End If

"Charlie Brown" wrote:
On Oct 5, 2:21 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
.Text is not available for .SelectedItem. I tried .ToString and got same
unwanted result.
"Charlie Brown" wrote:
On Oct 5, 1:42 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Say I have a control "CboColor" on a form with the "ITEMS" collection set to
list 'Red' and 'Blue' and the "TEXT" value set to 'Red'. I'm trying to get
the value of the control via code as such:
Dim strCboColorVal
strCboColorVal = Me.CboColor.Tex t()
Then to check if it's working:
Debug.Print(str CboColorVal)
And the value 'Red' occurs even if 'Blue' is selected in the dropdown box.
"Charlie Brown" wrote:
On Oct 5, 12:36 pm, Donald Fisher
<DonaldFis...@d iscussions.micr osoft.comwrote:
Hello. I'm trying to capture a controls value: a dropdown box with two
selections (either "Red" or "Blue") keeps returning the value "Red" even if
"Blue" is selected?
Donald, which property are you using to access the value? Could you
post you code as well?- Hide quoted text -
- Show quoted text -
Try using...
strCboColorVal = Me.CboColor.Sel ectedItem.Text- Hide quoted text -
- Show quoted text -
Sorry, I mistyped on that last one...
strCboColorVal = Me.CboColor.Sel ectedText- Hide quoted text -
- Show quoted text -

Assuming you used the designer property dialog to set the Items
collection by typing Red on the first line, and Blue on the second
line, the follwing code will produce th correct result...

If frmMain.cboOdue Color.SelectedI tem.ToString = "Red" Then

....

End If

will give you the result you are looking for.

Oct 6 '07 #9
"Donald Fisher" <Do**********@d iscussions.micr osoft.comschrie b
Still not working. I'm using this code from a separate class to
catch/use
the values of the controls but they are only returning the values
they were
set to at design time. How to return current values?

Dim strFontSize
strFontSize = frmMain.NumFont Size.Value.ToSt ring
If strFontSize = 10 Then
Debug.Print(str FontSize)
ElseIf strFontSize = 17 Then
Debug.Print(str FontSize)
End If
Dim ODueFontColor, ODueFontColorVa l
ODueFontColor = frmMain.CboOdue Color.SelectedI tem.ToString
If ODueFontColor = "Red" Then
ODueFontColorVa l = 3
Debug.Print(ODu eFontColorVal)
ElseIf ODueFontColor = "Blue" Then
ODueFontColorVa l = 5
Debug.Print(ODu eFontColorVal)
End If

First, it's strongly recommended to enable Option Strict. This code is slow,
unsafe and is doing unnecessary conversions.

Are you using different instances of the Form? Ist frmMain the visible
instance of the Form that you want to refer to? If you are not sure, set a
break point at the first line and have a look at frmMain.visible .
Armin

Oct 6 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3779
by: Dos Lil | last post by:
I have a unbound field in the subform(for calculating the datediff) which has the control property ==DateDiff("n",,). I have another unbound field in the main form which is for displaying the datediff from the subform.I have set the controls source = .Form! FRM- TimeSheet Subform is the name of the subform and TXTTtalHoursworked is the name of the unbound field in the subform.
3
6340
by: Pat | last post by:
Hello, I've used Sum() to total bound fields on a continuous form with no problem. However, I now have a continuous form, on which I use an unbound field to calculate the number of hours between two times stored in a record (bound fields). This field is called txtDuration. On my footer, I've created another unbound field named txtWeeklyTotal. I've set the Control Source to =Sum(), but this returns a #Name? error. I've tried . and it...
3
2358
by: Trevor Hughes | last post by:
I am trying to resolve a problem I'm experiencing in Access 2000. I have an unbound control which is set be code on the open event of a form. However when I try to subsequently run some code which references the value in the unbound control, the code cannot see the value set. If however I manually type in the value into the unbound control the code works fine. I have tried to Refresh and Repaint the form, but this does not solve the...
3
2756
by: google | last post by:
I'm developing an application for use within my company in Access 2003. I'm new to '03, the application I did for my former employer was in '97. The two applications have similar functionality (we're sales offices, and I'm doing things such as associate directories, commission calculations, order tracking, etc.). 2003 seems to have a few extra features, but I seem to continually run in to oddities that seem like they SHOULD work, but...
18
3802
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having trouble. I have tried keeping some of the fields bound and when I use the save button it has been saving as 2 different records. This is unacceptable. This is what I have, can anyone help me out with this?
5
2722
by: luanhoxung | last post by:
hi all!! i face to a new trouble. in my form, i have a textbox(unbound) that informs details of product when i choose the value of combo box(IDPro). it is ok when i choose the first value of IDPro. but in the second one, the texbox show as same as first. here my code. Private Sub IDPro_AfterUpdate() DETAIL.Value = DLookup("", "TProducts", IDPro = Me.IDPro)
3
11278
by: Richard | last post by:
How is the result of query placed in a unbound textbox ? Suppose CriteriaLookups has columns TableName, KeyColumn, KeyValue, DataColumn Foo,x,11,xhat Bar,z,3,xyzzy And
28
3272
by: jverri01 | last post by:
First, I am relatively new to working with variables. Most of my experience has been with interface design. i am using ACCESS ver. 2003, running in Windows XP. Second, I spent an hour searching through articles and posts to make sure the information I am seeking is not already posted on the site. I am beating my head against the wall trying to figure out something that seems like it should be very simple. The trouble is I do not fully...
11
5190
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command button will open a new form (Form2). Form2 has two subforms. Both are embedded in the main form. (Subform2 is NOT embedded in subform1.) Subform1 displays records as a continuous form based on the Primary ID of the main form and lists the...
0
9641
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10146
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9944
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6735
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5378
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2875
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.