PDA

View Full Version : Adding Jpg to Access



RonNCmale
12-17-2008, 07:38 PM
I have this code and works great, with the small exception that when the jpg is added it goes to the first entry of the database. I need when the jpg is added it stays on that data entry. I hope this is clear?

Private Sub cmdAddImage_Click()
On Error GoTo cmdAddImage_Err
Dim strFilter As String
Dim lngflags As Long
Dim varFileName As Variant

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![frmSTG].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

Demosthine
12-17-2008, 10:44 PM
Evening there.

I do believe that the Forms![frmSTG].Form.Requery is your problem. In general, when you requery, it might adjust the number of Records, and therefore the location of the current Record you were editing. It has to return to the first Record in order to preserve the data's integrity.

Scott