My Assistant
![]() ![]() |
|
|
Dec 12 2008, 03:56 PM
Post
#1
|
|
|
UtterAccess Veteran Posts: 354 From: B'ham, AL |
I'm trying to get a combo box to behave but it's not doing what I want. When I open a form I'd like for my combo box to show one value if a date field is Not Null and show another value if the same date field Is Null. I'm using the following code when I load the form:
If IsNull(Me.Read_Date) Then Me.ResultID.Column(0) = 6 Else Me.ResultID.Column(0) = 1 The combo box contains two columns, the first column is bound to an autonumber in a lookup table. I can set the default to Value 1 when the form opens, however, if there isn't a date then I can't get it to open with a different value. Any suggestions, pointers, hints or tips would be appreciated. Thanks, tony |
|
|
|
Dec 12 2008, 04:15 PM
Post
#2
|
|
|
UA Editor + Utterly Certified Posts: 22,722 From: Melton Mowbray,Leicestershire (U.K) |
Hi
To set/select a particular row of a combo you could use: CODE Me.ComboName = Me.ComboName.ItemData([color="red"]?[/color]) (?) would be the row number..(1,6) Remember the first row is (0) (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif) |
|
|
|
Dec 12 2008, 04:17 PM
Post
#3
|
|
|
UtterAccess VIP Posts: 2,135 From: Plano, TX |
It also looks like you may be trying to reference the field that the combo is bound to, you should be referencing the name of the comboBox, just as Larry has pointed out above.
HTH |
|
|
|
Dec 12 2008, 04:24 PM
Post
#4
|
|
|
UtterAccess Veteran Posts: 354 From: B'ham, AL |
I tried your suggestion but receive a "You can't assign a value to this object" error message.
|
|
|
|
Dec 12 2008, 04:30 PM
Post
#5
|
|
|
UA Editor + Utterly Certified Posts: 22,722 From: Melton Mowbray,Leicestershire (U.K) |
Hi
Can we now see the actual code with the newly add line..!! (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif) |
|
|
|
Dec 12 2008, 04:33 PM
Post
#6
|
|
|
UtterAccess Veteran Posts: 354 From: B'ham, AL |
This is how my code looks:
If IsNull(Me.Read_Date) Then Me.ResultID = Me.ResultID.ItemData(5) Else Me.ResultID = Me.ResultID.ItemData(0) |
|
|
|
Dec 12 2008, 04:44 PM
Post
#7
|
|
|
UA Editor + Utterly Certified Posts: 22,722 From: Melton Mowbray,Leicestershire (U.K) |
Hi
Ok.. I've trialed & tested it.. On the forms open event.. CODE If IsNull(Me.Text7) Then Me.Combo0 = Me.Combo0.ItemData(3) Else Me.Combo0 = Me.Combo0.ItemData(2) End If My combo has (4) values... 0 1 2 3 Does your combo have (6) or more rows/values..!!! (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif) |
|
|
|
Dec 12 2008, 05:00 PM
Post
#8
|
|
|
UtterAccess Veteran Posts: 354 From: B'ham, AL |
My combo has five(5) rows. I've gone back and adjusted the row designator to 0 and 4, but I still get the same error. Also, I'm doing this on a Form Load ( ); but I did go back and try it on a Form Open and I still get the same message.
Would it matter that my combo consists of two columns; the first column is not visible and it's also the bound column that I'm trying to change. |
|
|
|
Dec 12 2008, 05:08 PM
Post
#9
|
|
|
UA Editor + Utterly Certified Posts: 22,722 From: Melton Mowbray,Leicestershire (U.K) |
Hi
If you have (5) rows all that can be selected is: 0 1 2 3 4 (5) is out of range... The number of columns is irrelevant.. (IMG:http://www.utteraccess.com/forum/style_emoticons/default/thumbup.gif) |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 23rd May 2013 - 11:00 AM |