Quick Help - In Need
This is your typical phonebook that stores info fields and 1 picture with each entry. Im just trying to make it store 4 pictures total, for each entry and I can't figure out the code for the life of me. I been searching the internet for over two-weeks and even rented out books from the library.
http://mywebpages.comcast.net/mex/help1.jpg
Help me please. VB6 Project files can be downloaded.. http://mywebpages.comcast.net/mex/dbimage.zip
Anyone with a working solution to this will receive a apreciation lump sum via PayPal.
Dim conServer As Connection
Dim rstData As Recordset
Dim updFlags As Byte
Private Sub cmdManipulate_Click(Index As Integer)
On Error GoTo Handler
Select Case Index
Case 0 'New
updFlags = 1 'Seting for New
Me.picEmp.Picture = LoadPicture("")
Me.Image1.Picture = LoadPicture("")
EnableFields ("New")
Case 1 'Modify
updFlags = 2 'For Modify
EnableFields ("Modify")
Case 2 'Save
With rstData
If updFlags = 1 Then .AddNew
![EmpName] = Me.txtEmpName
![EmpAge] = Me.txtAge
GetPhoto Me.lblPhoto.Caption, rstData, "EmpPhoto", "EmpPhotoSize"
.Update
End With
EnableFields ("Fill")
Case 3 'Cancel
EnableFields ("Fill")
FillData
End Select
Exit Sub
Handler:
On Error Resume Next
MsgBox "Error Occured While Handling Command" & vbCrLf & Err.Description, vbInformation
EnableFields ("Fill")
FillData
End Sub
Private Sub cmdNavigate_Click(Index As Integer)
On Error Resume Next
Select Case Index
Case 0 'First
rstData.MoveFirst
With cmdNavigate
.Item(1).Enabled = False
.Item(2).Enabled = True
End With
Case 1 'Previous
rstData.MovePrevious
With cmdNavigate
If rstData.BOF Then
.Item(0).SetFocus
.Item(1).Enabled = False
rstData.MoveFirst
End If
.Item(2).Enabled = True
End With
Case 2 'Next
rstData.MoveNext
With cmdNavigate
If rstData.EOF Then
.Item(3).SetFocus
.Item(2).Enabled = False
rstData.MoveLast
End If
.Item(1).Enabled = True
End With
Case 3 'Last
rstData.MoveLast
With cmdNavigate
.Item(1).Enabled = True
.Item(2).Enabled = False
End With
End Select
FillData
End Sub
Private Sub cmdPhoto_Click()
On Error Resume Next
With Me.cmDlg
.Filter = "All Graphic Files |*.Gif;*.Jpg;*.bmp;*.wmf;"
.DialogTitle = "Find Employee Photo"
.ShowOpen
Me.lblPhoto.Caption = Me.cmDlg.filename
Me.picTmp.Picture = LoadPicture(Me.cmDlg.filename)
Me.picEmp.Picture = picTmp.Picture
Me.Image1.Picture = Me.picEmp.Picture
Me.VScroll1.Max = (picEmp.ScaleHeight - Me.Picture1.ScaleHeight) / 5
Me.HScroll1.Max = (picEmp.ScaleWidth - Me.Picture1.ScaleWidth) / 5
End With
End Sub
Private Sub cmdPhoto2_Click()
On Error Resume Next
With Me.cmDlg
.Filter = "All Graphic Files |*.Gif;*.Jpg;*.bmp;*.wmf;"
.DialogTitle = "Find Employee Photo"
.ShowOpen
Me.lblPhoto.Caption = Me.cmDlg.filename
Me.picTmp.Picture = LoadPicture(Me.cmDlg.filename)
Me.picEmp.Picture = picTmp.Picture
Me.Image1.Picture = Me.picEmp.Picture
Me.VScroll1.Max = (picEmp.ScaleHeight - Me.Picture1.ScaleHeight) / 5
Me.HScroll1.Max = (picEmp.ScaleWidth - Me.Picture1.ScaleWidth) / 5
End With
End Sub
Private Sub cmdReset_Click()
On Error Resume Next
Me.HScroll2.Value = 0
Me.picEmp.Picture = Me.picTmp.Picture
End Sub
Private Sub Form_Load()
On Error GoTo Handler
Set conServer = New Connection
With conServer
.Provider = "Microsoft.Jet.OLEDB.3.51"
.ConnectionString = "Data Source=" & App.Path & "\DBPict.mdb"
.Open
End With
Set rstData = New Recordset
With rstData
.ActiveConnection = conServer
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open "SELECT * From Employees"
End With
If getRowsOk(rstData) Then
rstData.MoveFirst
FillData
End If
Exit Sub
Handler:
MsgBox Err.Description & vbCrLf & "Unable to Connect to Database", vbInformation
Unload Me
Exit Sub
End Sub
'Checks if there are records in Recordset
Private Function getRowsOk(rst As Recordset) As Boolean
On Error GoTo Handler
Dim varData
varData = rst.GetRows(1)
getRowsOk = True
Exit Function
Handler:
getRowsOk = False
End Function
'Fills Data into Form
Private Sub FillData()
On Error GoTo Handler
With rstData
Me.txtEmpName = ![EmpName]
Me.txtAge = ![EmpAge]
Call FillPhoto(rstData, "EmpPhoto", "EmpPhotoSize", Me.picEmp)
Me.picTmp.Picture = Me.picEmp.Picture
Me.Image1.Picture = picEmp.Picture
Me.VScroll1.Max = (picEmp.ScaleHeight - Me.Picture1.ScaleHeight) / 5
Me.HScroll1.Max = (picEmp.ScaleWidth - Me.Picture1.ScaleWidth) / 5
End With
EnableFields ("Fill")
Exit Sub
Handler:
Exit Sub
End Sub
Private Sub EnableFields(State As String)
On Error Resume Next
Select Case State
Case "Fill"
Me.txtEmpName.Locked = True
Me.txtAge.Locked = True
Me.cmdPhoto.Enabled = False
With Me.cmdManipulate
.Item(0).Enabled = True
.Item(1).Enabled = True
.Item(0).SetFocus
.Item(2).Enabled = False
.Item(3).Enabled = False
End With
Case "New"
Me.txtEmpName.Locked = False
Me.txtAge.Locked = False
Me.txtEmpName = ""
Me.txtAge = 0
Me.cmdPhoto.Enabled = True
With Me.cmdManipulate
.Item(2).Enabled = True
.Item(2).SetFocus
.Item(3).Enabled = True
.Item(1).Enabled = False
.Item(0).Enabled = False
End With
Case "Modify"
Me.txtEmpName.Locked = True
Me.txtAge.Locked = False
Me.cmdPhoto.Enabled = True
With Me.cmdManipulate
.Item(2).Enabled = True
.Item(2).SetFocus
.Item(3).Enabled = True
.Item(1).Enabled = False
.Item(0).Enabled = False
End With
End Select
End Sub
Private Sub HScroll1_Change()
On Error Resume Next
Me.picEmp.Left = -5 * Me.HScroll1
End Sub
Private Sub HScroll2_Change()
On Error Resume Next
Screen.MousePointer = vbHourglass
SetBrightness Me.picTmp, Me.picEmp, HScroll2.Value
Screen.MousePointer = vbNormalFocus
End Sub
Private Sub VScroll1_Change()
On Error Resume Next
Me.picEmp.Top = -5 * Me.VScroll1
End Sub

