3 Replies - 271 Views - Last Post: 01 October 2019 - 03:50 AM Rate Topic: -----

#1 rushi61   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-September 19

lisbox not working while pulling data from ms access database

Posted 30 September 2019 - 01:18 PM

HI guys I am using visual basic 6.0
and i am having problem ... actually the listboxes were working fine and suddently they stopped retriving data from ms access database, when i click on button ,,the listboxex stays blank...and the database is working fine with other activities or controls... i am posting my code bellow..thanks in advance

Private Sub Command1_Click()
Dim db2 As Database
Dim rs2 As Recordset
Dim Tot As Integer
Dim gst, gtot As Double
Tot = 0
Set db2 = OpenDatabase("D:\OrderMania\ordermania.mdb")
Set rs2 = db2.OpenRecordset("select * from order1")
While Not rs2.EOF
If StrConv(Text3.Text, vbProperCase) = rs2.Fields(7).Value And Text1.Text = rs2.Fields(0).Value And rs2.Fields(9).Value = "Waiting" And rs2.Fields(8).Value = "Pending" Then
MsgBox "Customer Yet to be Served", vbCritical, "Order Waiting"
Exit Sub
End If
rs2.MoveNext
Wend

While Not rs2.EOF
  If StrConv(Text3.Text, vbProperCase) = rs2.Fields(7).Value And Text1.Text = rs2.Fields(0).Value Then

      List1.AddItem (rs2.Fields(2).Value)
      List2.AddItem (rs2.Fields(4).Value)
      List3.AddItem (rs2.Fields(3).Value)
      List4.AddItem (rs2.Fields(5).Value)
      Text2.Text = rs2.Fields(1).Value
      Text7.Text = rs2.Fields(6).Value
      Tot = Tot + rs2.Fields(5).Value
      lblstatus.Caption = rs2.Fields(8).Value
    End If

If lblstatus.Caption = "Paid" Then
            lblstatus.ForeColor = vbGreen
            
Else
            lblstatus.ForeColor = vbRed
End If
rs2.MoveNext
Wend
Text6.Text = Tot
gst = Tot * 0.05
Text5.Text = gst
gtot = Tot + gst
Text4.Text = gtot
End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: lisbox not working while pulling data from ms access database

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15728
  • View blog
  • Posts: 63,014
  • Joined: 12-June 08

Re: lisbox not working while pulling data from ms access database

Posted 30 September 2019 - 01:24 PM

Are there any exceptions?
If you put a breakpoint on top does it step through everything correctly?
Has Access been updated, changed machines, etc?
Was This Post Helpful? 1
  • +
  • -

#3 rushi61   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-September 19

Re: lisbox not working while pulling data from ms access database

Posted 01 October 2019 - 03:40 AM

View Postmodi123_1, on 30 September 2019 - 01:24 PM, said:

Are there any exceptions?
If you put a breakpoint on top does it step through everything correctly?
Has Access been updated, changed machines, etc?


thanks for the reply...and yes..i converted "exit sub" line to comment and it still not working and yes i changed my access database but it working fine in other forms and even in this bloxk of code the first while loop is working perfectly which is as follows problem occurs after that while loop

While Not rs2.EOF
If StrConv(Text3.Text, vbProperCase) = rs2.Fields(7).Value And Text1.Text = rs2.Fields(0).Value And rs2.Fields(9).Value = "Waiting" And rs2.Fields(8).Value = "Pending" Then
MsgBox "Customer Yet to be Served", vbCritical, "Order Waiting"
Exit Sub
End If
rs2.MoveNext
Wend


View Postmodi123_1, on 30 September 2019 - 01:24 PM, said:

Are there any exceptions?
If you put a breakpoint on top does it step through everything correctly?
Has Access been updated, changed machines, etc?


no i did not use any exception in whole project
Was This Post Helpful? 0
  • +
  • -

#4 rushi61   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-September 19

Re: lisbox not working while pulling data from ms access database

Posted 01 October 2019 - 03:50 AM

View Postmodi123_1, on 30 September 2019 - 01:24 PM, said:

Are there any exceptions?
If you put a breakpoint on top does it step through everything correctly?
Has Access been updated, changed machines, etc?



yooo its working now... i did a small change in my code... in 1st while loop in "if statement" after "exit sub" i added "GoTo 1"
and before 2nd while loop i wrote "1"...now now compiler is going to the 2nd while loop if the condition is false...

and thanks for the reply...i was thinking that i wont get a reply on this question because the vb6 is very old language...but unfortunatly we still have it in our syllabus...

thanks again....

View Postmodi123_1, on 30 September 2019 - 01:24 PM, said:

Are there any exceptions?
If you put a breakpoint on top does it step through everything correctly?
Has Access been updated, changed machines, etc?



yooo its working now... i did a small change in my code... in 1st while loop in "if statement" after "exit sub" i added "GoTo 1"
and before 2nd while loop i wrote "1"...now now compiler is going to the 2nd while loop if the condition is false...

and thanks for the reply...i was thinking that i wont get a reply on this question because the vb6 is very old language...but unfortunatly we still have it in our syllabus...

thanks again....
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1