Code:
Dim db As Database
Dim rs As Recordset
Dim WS As Workspace
Dim Max As Long
Private Sub Form_Load()
Set WS = DBEngine.Workspaces(0)
DbFile = (App.Path & "\Database\AddressBook.mdb")
PwdString = "swordfish"
Set db = DBEngine.OpenDatabase(DbFile, False, False, ";PWD=" & PwdString)
Set rs = db.OpenRecordset("Addresses", dbOpenTable)
Max = rs.RecordCount
lblTotalContacts.Caption = Max
If rs.RecordCount = 0 Then
Exit Sub
Else
rs.MoveFirst
List1.Clear
For i = 1 To Max
List1.AddItem rs!FullName
rs.MoveNext
Next i
List1.ListIndex = 0
End If
ButtonsEnabled
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
ButtonsEnabled
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub List1_Click()
Set WS = DBEngine.Workspaces(0)
DbFile = (App.Path & "\Database\AddressBook.mdb")
PwdString = "swordfish"
Set db = DBEngine.OpenDatabase(DbFile, False, False, ";PWD=" & PwdString)
Set rs = db.OpenRecordset("Select * from Addresses where FullName = '" & Trim(List1.List(List1.ListIndex)) & "'")
On Error GoTo ErrorHandler
lblName.Caption = rs("FullName")
lblNationality.Caption = rs("Nationality")
lblCountry.Caption = rs("Country")
lblBirthday.Caption = rs("Birthday")
lblCountry.Caption = rs("Country")
lblCity.Caption = rs("City")
lblAddress.Caption = rs("Address")
lblPhoneNumber.Caption = rs("PhoneNumber")
lblMobile.Caption = rs("Mobile")
lblFax.Caption = rs("Fax")
lblEMAIL.Caption = rs("E-Mail")
lblWebSite.Caption = rs("WebSite")
lblCompany.Caption = rs("Company")
Text1.Text = rs("LittleComment")
ErrorHandler:
Resume Next
End Sub
Comment