S
Secret Squirrel
I have a form with a listbox in it that shows all my employees. When I open
the form I have it set to go to the first record in the list and show that
employees record. This is how I have it set up in the open event of my form:
Me.EmployeeList = Me.EmployeeList.ItemData(0)
I have a command button on my form that allows me to add a link to their
picture file. After I click on this command button and select the file it
then reverts back to the first record but in the list box it still highlights
the employee I just added the link to. In order for me to get back to that
record I click on their name again in the listbox and it shows that employees
info.
My question is how can I have it not revert back to the first record in my
table after I run this command? I want to have it stay on that employees
record after I add the link. Here is the code I'm using on my command button:
Private Sub cmdAddImage_Click()
On Error GoTo cmdAddImage_Err
Dim strFilter As String
Dim lngflags As Long
Dim varFileName As Variant
Me.LastName.SetFocus
strFilter = "All Files (*.*)" & vbNullChar & "*.*" _
& vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
lngflags = tscFNPathMustExist Or tscFNFileMustExist _
Or tscFNHideReadOnly
varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngflags, _
strDialogTitle:="Please choose a file...")
If IsNull(varFileName) Then
Else
Me![memProperyPhotoLink] = varFileName
Forms![frmEmployeeMain].Form.Requery
End If
cmdAddImage_End:
On Error GoTo 0
Exit Sub
cmdAddImage_Err:
Beep
MsgBox Err.Description, , "Error: " & Err.Number _
& " in file"
Resume cmdAddImage_End
End Sub
the form I have it set to go to the first record in the list and show that
employees record. This is how I have it set up in the open event of my form:
Me.EmployeeList = Me.EmployeeList.ItemData(0)
I have a command button on my form that allows me to add a link to their
picture file. After I click on this command button and select the file it
then reverts back to the first record but in the list box it still highlights
the employee I just added the link to. In order for me to get back to that
record I click on their name again in the listbox and it shows that employees
info.
My question is how can I have it not revert back to the first record in my
table after I run this command? I want to have it stay on that employees
record after I add the link. Here is the code I'm using on my command button:
Private Sub cmdAddImage_Click()
On Error GoTo cmdAddImage_Err
Dim strFilter As String
Dim lngflags As Long
Dim varFileName As Variant
Me.LastName.SetFocus
strFilter = "All Files (*.*)" & vbNullChar & "*.*" _
& vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
lngflags = tscFNPathMustExist Or tscFNFileMustExist _
Or tscFNHideReadOnly
varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngflags, _
strDialogTitle:="Please choose a file...")
If IsNull(varFileName) Then
Else
Me![memProperyPhotoLink] = varFileName
Forms![frmEmployeeMain].Form.Requery
End If
cmdAddImage_End:
On Error GoTo 0
Exit Sub
cmdAddImage_Err:
Beep
MsgBox Err.Description, , "Error: " & Err.Number _
& " in file"
Resume cmdAddImage_End
End Sub