Arthur Fuller
artful at rogers.com
Mon Feb 10 11:20:30 CST 2003
It seems that the line between three questions has blurred. You very seldom want to test the length of a combo-box column. In fact, I can't think of one instance in which I wanted this value, since I could get this value not from the data but from the ColumnWidths property. Perhaps you're testing for the absence of data, in which case you're testing the wrong property. A combo-box has a zero-based array of columns. In the typical instance, the PK is in column 0 with a width of 0, so it's hidden. Some text field such as companyName is in column 1, with a width > 0 so it's visible. Other columns may appear or not. (I often add several invisible columns containing information I will need elsewhere in the form, for example the concert date or the ticket price or the current number of tickets available.) Given this: Me.cboName.Column(0) returns the PK in question. Me.cboName.Column(1) returns the carbon-unit-friendly text. Me.cboName.Column(n) returns one of the invisible columns mentioned above. Before doing anything else, test that the combo is not null. If Not IsNull(me.cboName) Then doStuff End If It could be that column(n) in the selected row is NULL, which fact may be important in your app. For example, if DepartmentID is NULL, enable the DepartmentID combo-box, else disable it. Me.cboDepartmentID.Enabled = IsNull(me.cboDepartmentID) Hth, Arthur -----Original Message----- From: accessd-admin at databaseadvisors.com [mailto:accessd-admin at databaseadvisors.com] On Behalf Of John Clark Sent: February 10, 2003 11:20 AM To: accessd at databaseadvisors.com Subject: [AccessD] length of combo box choice (shorter version) I have a combo box, in an A97 form, w/three columns. I want to test the length of one of these columns for some code that I have. How do I refer to a specific column in the syntax for the Len function? I used, "If Len(frmFEDSMain!cboResults.ItemsSelected) > 10 Then" and "Len([Forms]![frmFEDSMain]![cboResults].[Column](0))" but these do not work. I had used the first syntax origianlly, and it worked. But, I had forgotten to fill in the control source (I know...stupid), and it quit working, when I filled this in. I also tried a roundabout approach, by putting "chkstring = [Forms]![frmFEDSMain]![cboResults].[Column](0)" and sticking this variable into the Len function, but this returns 42 (or whatever the length of the actual string is). Any ideas? Thanks! John W Clark _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com