D
Daama via AccessMonster.com
Hi,
I really need some help!!!!
I have a list box displaying several items. The same items are also found in
a separate table named: "FieldDescription". In this table, there are 2 column:
one listing those items and the other column contains the description of each
item> What I want to do is create an OnClick event that checks if the
selected item from the list box is the same as one of the items in the table.
If true, then populate the textbox with the corresponding description from
the table.
I am using the code below but just can't get to work. It's not giving the
corresponding description.
P.S. I can write out the vba code and include the descriptions into the If..
then statement. But I'd like to keep the description seperate in a table so
that a user can edit it easily without going into the code.
Any Help!!!!
Below is the code
Daama
Public Sub btnOK_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
Dim strField As String
Dim X As Integer
Dim i As Integer
i = lstSelected.ListIndex
If i <> -1 Then
For X = 0 To Me.lstSelected.ListCount - 1
strField = Me.lstSelected.Value
Next X
rs.Open "FieldDescription", cn
If strField = rs.Fields.Item("FieldName") Then
txtFieldsDescription.SetFocus
txtFieldsDescription.Text = rs.Fields.Item("Description")
End If
End If
End Sub
I really need some help!!!!
I have a list box displaying several items. The same items are also found in
a separate table named: "FieldDescription". In this table, there are 2 column:
one listing those items and the other column contains the description of each
item> What I want to do is create an OnClick event that checks if the
selected item from the list box is the same as one of the items in the table.
If true, then populate the textbox with the corresponding description from
the table.
I am using the code below but just can't get to work. It's not giving the
corresponding description.
P.S. I can write out the vba code and include the descriptions into the If..
then statement. But I'd like to keep the description seperate in a table so
that a user can edit it easily without going into the code.
Any Help!!!!
Below is the code
Daama
Public Sub btnOK_Click()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
Dim strField As String
Dim X As Integer
Dim i As Integer
i = lstSelected.ListIndex
If i <> -1 Then
For X = 0 To Me.lstSelected.ListCount - 1
strField = Me.lstSelected.Value
Next X
rs.Open "FieldDescription", cn
If strField = rs.Fields.Item("FieldName") Then
txtFieldsDescription.SetFocus
txtFieldsDescription.Text = rs.Fields.Item("Description")
End If
End If
End Sub