Skip to content

Instantly share code, notes, and snippets.

@facebookegypt
Last active December 14, 2015 18:29
Show Gist options
  • Save facebookegypt/5129610 to your computer and use it in GitHub Desktop.
Save facebookegypt/5129610 to your computer and use it in GitHub Desktop.
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
End If
'-Save the data to the Database.
' A good practise on how to save/retrieve
'Photos [http://evry1falls.freevar.com/VB6/photo.html]
RS.AddNew
RS!Fname = Trim(Tnm.Text)
RS!Fmob = Trim(Tmob.Text)
RS!Fphone = Trim(Thp.Text)
'Saving the picture using the Binary method.
Rs_Stream.Type = adTypeBinary
Rs_Stream.Open
Rs_Stream.LoadFromFile PicNm
If Rs_Stream.Size > 0 Then
RS("Fpic") = Rs_Stream.Read
RS.Update
MsgBox "(1) entry saved successfully", vbOKOnly, "Done"
'Open stream must be closed, or you will get error
'(Operation not allowed in this context)
Rs_Stream.Close
Set Rs_Stream = Nothing
ClearTxtBox
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment