کار با بانک اطلاعاتی

برای مشاهده بر روی ادامه مطلب کلید کنید... .

Dim rs As Recordset

Dim db As Database

Private Sub Form_Load()

'Set db = OpenDatabase("E:\Users\homayoon\Documents\Bank.mdb")

Set db = OpenDatabase(App.Path & "\Bank.mdb")

Set rs = db.OpenRecordset("shop", dbOpenTable)

 CmbSearch.AddItem "ÞíãÊ ÇÌÇÑå"

  CmbSearch.AddItem "ÂÏÑÓ"

CmbSearch.ListIndex = 0

ListGenerate

End Sub

Private Function ListGenerate()

On Error GoTo errlbl

rs.MoveLast

rs.MoveFirst

Max = rs.RecordCount

rs.MoveFirst

lstShop(1).Clear

lstShop(0).Clear

For i = 1 To Max

    If rs("Name") <> "" Then

       lstShop(0).AddItem i

lstShop(1).AddItem rs("Name")

rs.MoveNext

  End I

Next i

rs.MoveFirst

lstShop(2).Clear

For l = 1 To Max

       If rs("Family") <> "" Then

lstShop(2).AddItem rs("Family")

            rs.MoveNext

   End If

Next

rs.MoveFirst

lstShop(3).Clear

For l = 1 To Max

       If rs("TEL") <> "" Then

lstShop(3).AddItem rs("TEL")

            rs.MoveNext

       ElseIf l <= Max Then

  lstShop(3).AddItem "ÎÇáí"

            rs.MoveNext

       End If

Next l

rs.MoveFirst

lstShop(4).Clear

For l = 1 To Max

       If rs("Address") <> "" Then

 

lstShop(4).AddItem rs("Address")

        rs.MoveNext

    End If

Next l

rs.MoveFirst

lstShop(5).Clear

For l = 1 To Max

       If rs("GHRahn") <> "" Then

lstShop(5).AddItem rs("GHRahn")

            rs.MoveNext

       End If

Next l

rs.MoveFirst

lstShop(6).Clear

For l = 1 To Max

       If rs("GHEjare") <> "" Then

lstShop(6).AddItem rs("GHEjare")

            rs.MoveNext

       End If

Next l

rs.MoveFirst

lstShop(7).Clear

For l = 1 To Max

       If rs("Comment") <> "" Then

 

lstShop(7).AddItem rs("Comment")

            rs.MoveNext

       End If

Next l

errlbl:

Select Case Err

Case 3021:                              'If "No Current Record" Error Accourd

    Resume Next

End Select

End Function

Private Sub txtsearch_Change()

Select Case CmbSearch.Text

Case "ÞíãÊ ÇÌÇÑå":

    If txtsearch.Text = vbNullString Then

Set rs = db.OpenRecordset("Shop", dbOpenTable)

    Else

       Set rs = db.OpenRecordset("SELECT * FROM Shop  WHERE Ghejare LIKE '" & txtsearch.Text & "'" & "& '*'")

    End If

ListGenerate

Case "ÂÏÑÓ":

    If txtsearch.Text = vbNullString Then

Set rs = db.OpenRecordset("Shop", dbOpenTable)

    Else

 

        Set rs = db.OpenRecordset("SELECT * FROM Shop WHERE Address LIKE '" & txtsearch.Text & "'" & "& '*'")

    End If

ListGenerate

End Select

End Sub

نوشته شده در تاریخ پنجشنبه 19 آذر 1388    | توسط: محمد و مجید َ    |    |
نظرات()