Results 1 to 3 of 3

Thread: List Jpgs (A2k)

  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    List Jpgs (A2k)

    The following function fills a list box "lstPreviewJpgs".
    The images are loaded into "C:BICImage" via a VB6 utility which enables the user to add An Estimate No & Registration.
    example:

    13.jpg will be held in the folder as 12544-DU02THG-13.jpg

    Can the below code be altered to only show, or filter images with the left 5 most characters.

    So if on form "frmImages" which has [EstimateNo] of 12544,the list will only show images starting with 12544.
    Obviously if the record changes on the form ie 12545, then only images once again prefixed by 12545 will show.



    Function ListJPGs(fld As Control, id As Variant, _
    row As Variant, col As Variant, _
    Code As Variant) As Variant
    Static dbs(127) As String, Entries As Integer
    Dim ReturnVal As Variant
    ReturnVal = Null
    Select Case Code
    Case acLBInitialize ' Initialize.
    Entries = 0
    dbs(Entries) = Dir("C:BICimage*.jpg")
    Do Until dbs(Entries) = "" Or Entries >= 127
    Entries = Entries + 1
    dbs(Entries) = Dir
    Loop
    ReturnVal = Entries
    Case acLBOpen ' Open.
    ' Generate unique ID for control.
    ReturnVal = Timer
    Case acLBGetRowCount ' Get number of rows.
    ReturnVal = Entries
    Case acLBGetColumnCount ' Get number of columns.
    ReturnVal = 1
    Case acLBGetColumnWidth ' Column width.
    ' -1 forces use of default width.
    ReturnVal = -1
    Case acLBGetValue ' Get data.
    ReturnVal = dbs(row)
    Case acLBEnd ' End.
    Erase dbs
    End Select
    ListJPGs = ReturnVal
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List Jpgs (A2k)

    Dave,

    Modify the function as follows (changes indicated in bold):

    Function ListJPGs(fld As Control, id As Variant, row As Variant, _
    col As Variant, Code As Variant) As Variant
    Static dbs(127) As String, Entries As Integer
    Dim ReturnVal As Variant
    Dim strLeft5 As String
    strLeft5 = Left(Me.[EstimateNo], 5)
    ReturnVal = Null
    Select Case Code
    Case acLBInitialize ' Initialize.
    Entries = 0
    dbs(Entries) = Dir("C:BICimage" & strLeft5 & "*.jpg")
    Do Until dbs(Entries) = "" Or Entries >= 127
    Entries = Entries + 1
    dbs(Entries) = Dir
    Loop
    ReturnVal = Entries
    Case acLBOpen ' Open.
    ' Generate unique ID for control.
    ReturnVal = Timer
    Case acLBGetRowCount ' Get number of rows.
    ReturnVal = Entries
    Case acLBGetColumnCount ' Get number of columns.
    ReturnVal = 1
    Case acLBGetColumnWidth ' Column width.
    ' -1 forces use of default width.
    ReturnVal = -1
    Case acLBGetValue ' Get data.
    ReturnVal = dbs(row)
    Case acLBEnd ' End.
    Erase dbs
    End Select
    ListJPGs = ReturnVal
    End Function

    You will have to requery the list box in the On Current event of the form and in the After Update event of EstimateNo:

    Private Sub Form_Current()
    Me.lstPreviewJPGs.Requery
    ' Other code for On Current goes here
    End Sub

    Private Sub EstimateNo_AfterUpdate()
    Me.lstPreviewJPGs.Requery
    ' Other code for After Update goes here
    End Sub

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List Jpgs (A2k)

    Thanks Hans

    I changed as you advised but on Compile, the Me in:-

    strLeft5 = Left(Me.[EstimateNo], 5)

    Is not liked, invalid use of Me.
    The code is in a module not behind the form.
    I changed to :

    strLeft5 = Left(forms!frmImages.[EstimateNo], 5)

    And it works.
    There's a small prob with the requery though, I think I can solve that though.
    Thanks again.

Posting Permissions

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