Combo Box "Value List" - Run Time Error '2176'

S

stelios

Hi,
I have a combobox which I fill it with a "Value List" from code.
The Problem is: When the "Value List" is greater than 2050 aprox. characters
long I have a run time error '2176' that the value is too long. How Can i
fill it with rows that have length at total more than 2050 aprox.
characters? The "Value List" is character limited?

Thanks in advanced!
Stelios

ps.: (Below is a part of the code)

'###########################################################################
################
Dim RS As recordset
Dim SQLxxx, lstValues, Mon As String
Dim Id As Long

lstValues = ""

Con 'conection function to backend database with dbData the database
object

Me!cboxxxId.RowSourceType = "Value List" 'cboxxxId is the combo box
I want to fill

SQLxxx = "SELECT xxxID, xxx FROM Tablexxx " & _
"WHERE (((yyyID)=" & Me.cboyyyId & ")) " & _ 'Me.cboyyyId
is another combobox by which i filter the cboxxxId combobox
"ORDER BY xxx"

Set RS = dbData.OpenRecordset(SQLxxx, dbOpenDynaset)

If RS.RecordCount <> 0 Then
With RS
.MoveLast
.MoveFirst
Do Until .EOF
Id = !xxxID
Mon = !xxx
Decrypt Mon 'Decrypt is a function by which i
decrypt the data from the table
Mon = DecryptedString
lstValues = lstValues & Id & ";" & Mon & ";"
.MoveNext
Loop
Me!cboxxxId.RowSource = lstValues
End With
End If
 
P

Pavel Romashkin

You could put the values into a temporary table and use an SQL statement
to populate the row source. I personally would use the SQL you use to
generate the recordset, directly. As far as I can tell the reason for a
loop and a value list is decryption of the values, which I am sure is
totally unjustified given they are going to be publically displayed in a
combo box.
And if I am not mistaken, you can attach a recordset to a combo box,
although up to Access 2002 I think it could not be a disconnected
recordset. Maybe it can now in 2003 - I have not tried. But in your case
it is a connected recordset, so it might work.

Pavel
 
S

stelios

Hi Pavel and all Others,

The only reason i make the loop is because the data are encrypted and i must
decrypt them every time i fill the combobox.
I m using access 2k.
If I insert the "lstValues" with semicolumns data separated in a temp field
of a table and then set the "Me!cboxxxId.RowSource" to the "lstValues" will
it work or I will have again the same run time error?

Thanks,

Stelios
 
S

stelios

Hi Pavel and all Others,

The only reason i make the loop is because the data are encrypted and i must
decrypt them every time i fill the combobox.
I m using access 2k.
If I insert the "lstValues" with semicolumns data separated in a temp field
of a table and then set the "Me!cboxxxId.RowSource" to the "lstValues" will
it work or I will have again the same run time error?

Thanks,

Stelios
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top