ListBox Issues

T

Trepalium

I am having difficulty with a listbox currently. I am setting the
bound column property through VBA using the code

List2.BoundColumn = 11

There are 11 columns. The default bound column is 1 in my properties.

This code worked literally 5 minutes ago, but now it does not. Is
there any reason that a bound column wouldn't work? Code below. This
code is being executed when a command button is being clicked.
--------------------------------------------------------------------------------------------------------------------------------------------
Dim PstClsNme As String, PstClsID As String, PstClsAssignDte As Date,
AppID As String, Tpe As String
List2.BoundColumn = 11
Tpe = List2.Value
If Tpe = "D2RE" Then
D2RE = True
ElseIf Tpe = "Partner" Then
Partner = True
End If
List2.BoundColumn = 2
Combo2.SetFocus
PstClsNme = Combo2.Text
Call DBConnect
sql = "SELECT USERID, NAME FROM " & tblUserData & " WHERE NAME = '" &
PstClsNme & "'"
rsdata.Open (sql)
If rsdata.EOF Then
MsgBox "Post-Closer could not be located!", vbCritical, "Post-
Closer Not Found!"
rsdata.Close
Else
PstClsNme = rsdata("Name")
PstClsID = rsdata("USERID")
PstClsAssignDte = Format(Date, "mm/dd/yyyy")
AppID = List2.Value
rsdata.Close
sql = "INSERT INTO " & tblFileAssign & " VALUES ('" & PstClsID &
"', '" & PstClsNme & "','" & AppID & "','" & PstClsAssignDte & "')"
rsdata.Open (sql)
If D2RE = True Then
sql = "UPDATE " & tblCustInfoD2RE & " SET ASSIGNED = 1 WHERE
CLAPPLNUMBER = '" & AppID & "'"
rsdata.Open (sql)
List2.RemoveItem (AppID)
ElseIf Partner = True Then
End If

End If

--------------------------------------------------------------------------------------------------------------------------------------------

Column 11 tells if a particular item is D2RE or Partner. They are both
strings.

Any help would be appreciated.
 
G

George Nicholson

Well, that's a very inventive approach, but I would strongly advise against
changing the BoundColumn property via code while data is loaded. Since
BoundColumn determines what values get stored in the ControlSource, you run
a real risk of royally fouling up your data (especially since I don't see
you changing BoundColumn back to its original values...)

Use the Column property for Listbox/Combobox instead. Note that the
BoundColumn property is 1-based and the Column property is 0-based, So
..BoundColumn 2 and 11 are equivalent to .Column 1 and 10.

Tpe = List2.Column(10)
PstClsNme = Combo2.Column(1)
AppID = List2.Column(10) OR AppID = Tpe (doesn't it?)

Should be no need to set focus this way either.

HTH,
 
G

George Nicholson

Glad to help.

BTW, I was very serious when I said that you had an inventive approach. No
sarcasm included.
 
T

Trepalium

Glad to help.

BTW, I was very serious when I said that you had an inventive approach. No
sarcasm included.






- Show quoted text -

I appreciate your words.
 

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