Hi Guys
I am getting the above error message at the below line marked red. When I debug then the error comes when value of K is 10.
Hope any of you can help me to figure it out.
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim a As String
' Save the data in the table.
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0; " & _
"Data Source=J:\MailRoomMI1.mdb;"
Set rs = CreateObject("ADODB.Recordset")
strsql = "select * from tblmaster where UniqueID='" & TextBox1.Value & "'"
rs.Open strsql, cn
ListBox1.ColumnCount = rs.Fields.Count
i = 0
tot = rs.Fields.Count
j = 1
'Loop through all the records in the table until the EOF marker is reached.
Do While Not rs.EOF
For k = 0 To tot - 1
If IsNull(rs.Fields(k)) Or rs.Fields(k) = "" Then
a = "Null"
ElseIf rs.Fields(k).Value = 0 Then
a = "Null"
Else
a = rs.Fields(k).Value
End If
With Me.ListBox1
.AddItem
.List(i, k) = a
End With
Next k
i = i + 1
'Get the next record
rs.MoveNext
Loop
Thanks
Bookmarks