Skip to content

Instantly share code, notes, and snippets.

View facebookegypt's full-sized avatar

Ahmed Samir facebookegypt

View GitHub Profile
Private Sub CmdShow_Click()
'Manage Friends button displays the Display.frm form
Display.Show 1
End Sub
'1) Using ADO2.8 Technology to connect your Access DB.
Global CN As New ADODB.Connection
Global RS As New ADODB.Recordset
Private Sub Form_Load()
'Apply Graphics.
Form_Paint
'2-Connect to Database
If CN.State = 1 Then CN.Close
CN.Open ("Provider = Microsoft.Jet.OleDB.4.0 ; Data Source =" & App.Path & "\MyBook.Mdb")
'3)Connect Table Phones
If RS.State = 1 Then RS.Close
RS.CursorLocation = adUseClient
RS.Open ("Select * From Phones"), CN, adOpenDynamic, adLockOptimistic
Private Sub CmdSave_Click()
'4)Add new friend's phone #
'- Making sure the friend's name TextBox is not Empty,
'you can always add phone #s laters.
If Tnm.Text = Trim("") Then
MsgBox "Can't save data" & vbCrLf & _
"The name field is empty," & vbCrLf & "please fill the name field.", vbCritical, _
"Warning"
Tnm.SetFocus
Exit Sub
Private Sub Timg_Click()
'When clicking on the Timg control,
'Chat box appears to pic a photo
Cdl.Filter = ("Jpeg Jpg Photo Type (*.Jpg) |*.Jpg")
Cdl.CancelError = False
Cdl.DialogTitle = ("Choose a friend photo")
Cdl.ShowOpen
If Cdl.FileName = Trim("") Then
PicNm = App.Path & "/Phone1.Jpg"
Else
'General Declaration
Dim TxtCtrl As Control
Private Sub ClearTxtBox()
For Each TxtCtrl In Me.Controls
If TypeOf TxtCtrl Is TextBox Then
TxtCtrl.Text = Trim("")
End If
Next
Timg.Picture = LoadPicture(App.Path & "/Phone1.Jpg")
End Sub
Private Sub Form_Activate()
'connection for Holding the photo stream.
If Rs_Stream.State = adStateOpen Then Rs_Stream.Close
End Sub
Private Sub Form_Load()
'Display.frm code
Form_Paint
'Load friends from Database Table into ListBox control.
'Database is already connected as we did not terminate
Private Sub LstFrnds_Click()
'2) Retrieval of the stored data
'Searching the Database Table, where Criteria is Friend Name (Fname)
RS.MoveFirst
RS.Find "Fname = '" & LstFrnds.Text & "'"
If RS.EOF Then
MsgBox ("Something went wrong")
Exit Sub
End If
Label2.Caption = Trim("Name")
Private Sub CmdUp_Click()
'Updating friend Info
'Make sure the update proccess is actually an UPDATE ....
'1)
If Tnm.Text = Trim$("") Then
MsgBox "Please first, pick up a friend to update " & _
"his/her data", vbCritical, "Invalid Update Proccess"
Exit Sub
End If
'2)
Private Sub CmdDel_Click()
'Deleting a friend.
'Make sure the update proccess is actually an UPDATE ....
'1)
If Tnm.Text = Trim$("") Then
MsgBox "Please first, pick up a friend to remove " & _
"from friends list", vbCritical, "Invalid Delete Proccess"
Exit Sub
End If
'2)