Visual Basic Coding Help Please....

Sameira

Inactive User
Joined
Jul 20, 2005
Messages
1,505
Reaction score
1
Location
UK
Dim conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As ADODB.Recordset
Dim rs2 As ADODB.Recordset
Dim sConnString As String
Dim txtAppTitle As TextBox
Option Explicit
Private Sub cbCategory_Click()

'Creates the connection string to the database
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
App.Path & "\ComputerCare24.mdb"

'open the connection
conn.Open sConnString
Set cmd.ActiveConnection = conn

'gets information from the specific table and all required data
cmd.CommandText = "SELECT * Sub_Category FROM ProductInformation WHERE Category_no = " & rs2.Fields(0).Value

'sets the recordset to the above
Set rs2 = cmd.Execute

While Not rs2.EOF

cbSubCat.AddItem (rs2.Fields(0).Value)
rs2.MoveNext

Wend

'tidies everything up
Set rs2 = Nothing
Set cmd = Nothing
conn.Close
Set conn = Nothing
txtSearch.Text = ""

End Sub


it keeps cumin up wit a message sayin error 91 object variable or With block variable not set, thn wen i press debug it highlights this line yellow

cmd.CommandText = "SELECT * Sub_Category FROM ProductInformation WHERE Category_no = " & rs2.Fields(0).Value

-----------------------------------------------------------------------------------------------
wot im doin is:-

ther is one combo box which shows the categories, the other box shows the subcategories for tht specific category tht was cliked on, wen i teake out everythin on rs2 no error messages appear..


thnks...:)
 
TEST
Top