Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009

    Unanswered: Odd form behavior after inserting an image

    I have an inventory database that I designed basically to track my collection of model cars. I was able to add a browse button to add/link unique images to each form but every time I add a new image the form jumps back to the first record. The record that I was updating did update with the correct image but for some reason it always jump back to the first record.

    How can I add a new image and remain on the same form?

  2. #2
    Join Date
    Nov 2007
    Adelaide, South Australia
    The real question is what is it that is causing the behaviour.

    I suspect there is some code on your button that contains a Requery command. Get rid of it.

    The Requery command that is...
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!

    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Jan 2009
    Thanks for your help. I tried what you suggested and got rid of the Requery but now I'm receiving a Compile error: Invalid use of property.

    Here's the VB I'm using, it works fine if I leave the Requery. I just want it to stay on the current record if I add or delete images.

    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
    Me![path2image] = varFileName
    End If

    On Error GoTo 0
    Exit Sub

    MsgBox Err.Description, , "Error: " & Err.Number _
    & " in file"
    Resume cmdAddImage_End
    End Sub

    Function setImagePath()
    Dim strImagePath As String
    On Error GoTo PictureNotAvailable
    strImagePath = Me.path2image
    Me.path2image.Locked = True
    Me.path2image.Enabled = False
    Me.ImageFrame.Picture = strImagePath
    Exit Function
    strImagePath = "G:\DiecastInventory\DB_Images\NoImage.gif"
    Me.ImageFrame.Picture = strImagePath
    End Function

  4. #4
    Join Date
    Sep 2006
    If you saved your images according to a unique inveswtory ID or a unique Reference associated with the image you are just reading the image. I use a image ActiveX application but I did have a go in Access 2007 with:

    Function GetPicture()
    Dim FullPath As String
        With CodeContextObject
            FullPath = GetImageDir & .[Image File]
            If Dir([FullPath]) <> Empty Then
                .[ImageControl].Visible = True
                .[ImageControl].Picture = FullPath
                .[ImageControl].Visible = False
            End If
        End With
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts