943,686 Members | Top Members by Rank

Ad:
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jan 23rd, 2009
0

Re: problem in making listview

check out the bolded part of your code...i just mentioned the point where the code needs to be modified...

With BooK_Details
    set li = .ListItems.Add(, , (rs!Acc_No))
End With

get me a feedback if this works out...

regards
Shouvik
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007
Jan 24th, 2009
0

Re: problem in making listview

first of all my apology to all for reopening this SOLVED thread.

I am knid of new to vb programming, so maybe i am missing something. But Thanks a lot for the help. Actually i am still getting error. My actual connection is DSN. so do i have to write the code differently to connect my databse to ListView1..? I am kind of struggling with ListView and Database connection using DSN.

Set Li = . ListItems.Add (, ,(rs!Acc_No)) is corrected as you have instructed.
I am still getting this message when i compile.
Runtime Eror : '424'
Object Required


Thanks a lot again.
Have a good day.
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
chanthung is offline Offline
52 posts
since Jun 2008
Jan 24th, 2009
0

Re: problem in making listview

see there are many reasons for which you can get error 424...
for example,if u mistyped a control name which is not exist at all in your project aka form....or any dependencies like any external components that you referenced previously in your project but which is not exist presently....you might have uninstalled that from your system.....or you have used some variables in your code for which you haven't mentioned the correct datatype....

according to you....this problem can arise from your listview control....make sure that you typed the correct object name for the lv in your code.....lets say...in the code you have used listview1...make sure that you have the control on your form with object name "listview1".....otherwise the compiler won't recognize that...

or it will be more better...if you posted the actual ping point of your code where you are getting the error....may be post the full code if possible.....coz accroding to the code there is no error at all...but there seems to be some other error in the code...but for that the code needs to supervised...

now the choice is yours....

regards
Shouvik
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007
Jan 24th, 2009
0

Re: problem in making listview

Quote ...
My actual connection is DSN. so do i have to write the code differently to connect my databse to ListView1..?
whether you use DSN or DSN-Less connection, there is no need to write additional code for connecting lv with the database....just pass the connection string in form_load event, open the connection....make sure the you are using a global connection object....and that's it.....one global connection object will handle connecting to the database and this applies to all databound controls on your form....just make sure that the connection object is opened till you close the project....that's it...nothing else to do...

but you have to make sure that the DSN must exist in the ODBC admin. before you try to connect through your code....and ofcourse the connection string should differ in case of DSN connection rather that DSN-Less connection....

regards
Shouvik
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007
Jan 24th, 2009
0

Re: problem in making listview

try to remove the :

With BooK_Details
end with

and check the listview column you have.. by right click on the listview then goto properties and insert column as number of your fields loaded in the listview.

^_^
Reputation Points: 10
Solved Threads: 1
Junior Poster
jaasaria is offline Offline
123 posts
since Jul 2007
Jan 24th, 2009
0

Re: problem in making listview

Quote ...
try to remove the :

With BooK_Details
end with
why to remove that??? there is no error at this syntax at all....
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007
Jan 29th, 2009
0

Re: problem in making listview

Thanks to both of you for sharing your knowledge and sorry for my late response. Ok, so here is my code. This part of my program will accept a Book Name from the user and search through the database and display it in the List View else display Book not found message. Problem is I can’t find about List View in Books I am referring to. So I will be so grateful for help or suggestions..
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Command13_Click()
  2. Dim db As Database ‘Copied from your previous post.
  3. Dim rs As Recordset
  4. Dim li As ListItem
  5.  
  6. prompt$ = "Please enter full book name"
  7. SearchStr$ = InputBox(prompt$, "book title search")
  8. If SearchStr$ = "" Then Exit Sub ‘ Accept the Book Name
  9. ' from the user
  10. Form7.Data1.RecordSource = "select * from Book_Details where Book_Name like '" & SearchStr$ & "%'"
  11. Form7.Data1.Refresh
  12.  
  13. Set db = OpenDatabase(App.Path & "\libraryic.mdb")
  14. Set rs = db.OpenRecordset("Book_Details", dbOpenTable)
  15.  
  16. ''Do While Not Form1.Data1.Recordset.EOF
  17. ''Data1.Recordset.MoveNext ‘was trying this method earlier
  18. ''While Not Data1.Recordset.EOF
  19. If rs.RecordCount > 0 Then
  20. rs.MoveFirst
  21. While Not rs.EOF()
  22. ‘here I want to add the Columns and display all SubItems (DB records)
  23. With BooK_Details
  24. Set li = .ListItems.Add(, , (rs!Acc_No))
  25. li.SubItems(1) = IIf(IsNull(rs!Book_Name), "", rs!Book_Name)
  26. li.SubItems(2) = IIf(IsNull(rs!Author), "", rs!Author)
  27. li.SubItems(3) = IIf(IsNull(rs!Publisher), "", rs!Publisher)
  28. li.SubItems(4) = IIf(IsNull(rs!Stock), "", rs!Stock)
  29. li.SubItems(5) = IIf(IsNull(rs!Rack_No), "", rs!Rack_No)
  30. li.SubItems(6) = IIf(IsNull(rs!Classification_No), "", rs!Classification_No)
  31. End With
  32. rs.MoveNext
  33. Wend
  34.  
  35. Form7.Show
  36. End If
  37. End Sub
What I have in mind is this… but I am like all mixed up now!!
Acc No | Book Name | Author | Publisher
123 NNNN PP LLLL
234 BBBN YUH bpb
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
chanthung is offline Offline
52 posts
since Jun 2008
Feb 3rd, 2009
0

Re: problem in making listview

Can anyone please make a comment....so that i can go ahead.
Thanks
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
chanthung is offline Offline
52 posts
since Jun 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB Image resources and using them
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: plss give me some codes using palindrome in visual basic 6.0





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC