By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

ADODB Connection...

P: 56
I am doing a project in VB6 where i have made a bill consisting of various list boxes but i have problem retrieving data from the database using entry made in one of the list box. What i m trying to do is that on when a certain text box looses focus, an inputbox appears asking the code of product. This product code entered appears in a listbox and i want other listboxes to be filled with information from database that corresponds to the mentioned product code.(I am using ADODB).The following is the code i have written. please please tell me what is wrong.....Its really Urgent.....

The error i am getting is :OBJECT VARIABLE OR WITH BLOCK VARIABLE NOT SET.

Option Explicit
Dim response As Integer
Public rs As ADODB.Recordset

Private Sub txtDue_LostFocus()
response = InputBox("Enter Product Code", "Product Code")
lstProd.AddItem response

Call Connection
rs.Open "select * from Products where Prod_Code='" & lstProd.List(lstProd.ListIndex) & "' ", con, 3, 3

lstDescrptn.AddItem rs!Prod_Name
lstSalestax.AddItem rs!Salestax
con.Close

End Sub
Jan 22 '08 #1
Share this Question
Share on Google+
1 Reply


lotus18
100+
P: 866
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim response As Integer
  3. Public rs As ADODB.Recordset
  4.  
  5. Private Sub txtDue_LostFocus()
  6.    response = InputBox("Enter Product Code", "Product Code")
  7.    lstProd.AddItem response
  8.  
  9.    Call Connection
  10.    rs.Open "select * from Products where Prod_Code='" & lstProd.List(lstProd.ListIndex) & "' ", con, 3, 3
  11.  
  12.    lstDescrptn.AddItem rs!Prod_Name
  13.    lstSalestax.AddItem rs!Salestax
  14.    con.Close
  15.  
  16. End Sub
Hey response cannot be an integer type here : ) and also add a New keyword before As at line 3

Rey Sean
Jan 22 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.