Avoid jump to first data after update

rio

Registered User.
Local time
Tomorrow, 04:30
Joined
Jun 3, 2008
Messages
124
I try to follow the example in 'attachment' file to insert the image. The problem is after insert & update the data the form jump back to first data. Thats mean if I want to insert another data after insert the image so i have to search back to the previous data.

Anyone can help me to solve this problem???
 

Attachments

Change this:
Code:
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![frmProperties].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

to this:

Code:
Private Sub cmdAddImage_Click()
    On Error GoTo cmdAddImage_Err
    Dim strFilter As String
    Dim lngflags As Long
    Dim varFileName As Variant
[color=red]    Dim strBookmark As String[/color]

    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
[color=red]        strBookmark = Me.Bookmark[/color]
        Forms![frmProperties].Form.Requery
[color=red]        Me.Bookmark = strBookmark[/color]
    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
 
Thanks Boblarson.
It work 4 that file. Can I use this code for another database, if can ...should I change any part of this code?
As a beginner I'm not really expert with the code.
 
I used this code in my database:
**************************
Private Sub cmdAddImage1_Click()
On Error GoTo cmdAddImage1_Err
Dim strFilter As String
Dim lngflags As Long
Dim varFileName As Variant
Dim strBookmark As String
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![Gambar 1] = varFileName
strBookmark = Me.Bookmark
Forms![Borang_Inventori_BT].Form.Requery
Me.Bookmark = strBookmark
End If

cmdAddImage1_End:
On Error GoTo 0
Exit Sub

cmdAddImage1_Err:
Beep
MsgBox Err.Description, , "Error: " & Err.Number _
& " in file"
Resume cmdAddImage1_End

End Sub
**************************************
And then it show:

Error : 3159 in file
not a valid bookmark

Can u help me!! Why this happen??
 
First of all, you didn't declare

Dim strBookmark As String
 
Sorry.
how to declare it. Im already put the code like ur.
 
Well, originally I saw strGambar As String highlighted in red and no strBookmark as String.

Second, I was basing it on the code in the sample you posted. You have to make sure whatever you are using it in is working first the way it was working in your sample and then add the bookmark code.
 
I see.... Sorry about that..
before insert the extra code.. it's working fine. but only after insert the extra code it's come out with the problem I'm mention above. Where should i get the bookmark code or with what code i should change it. Can i replace it with the form name ([Borang_Inventori_BT]).
 
I see.... Sorry about that..
before insert the extra code.. it's working fine. but only after insert the extra code it's come out with the problem I'm mention above. Where should i get the bookmark code or with what code i should change it. Can i replace it with the form name ([Borang_Inventori_BT]).

Can you post your actual database? I can look at it just like I looked at the sample.
 
I try to upload my file. But it fail. Then i make a new one using same as my database. so hopefully u can help me to solve the problem.
 

Attachments

Users who are viewing this thread

Back
Top Bottom