Results 1 to 3 of 3

Thread: Make reference qry record source of form

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2000
    Location
    New Zealand
    Posts
    35

    Make reference qry record source of form

    Any advice appreciated. Beacon - took note of your comments, trying a diff approach!

    Having problems getting image to load in an unbound object frame (imageFrame1), based on selction made in combo box.

    Tried this code in Combo afterUpdate event:

    Private Sub cboBridgeID_AfterUpdate()

    Dim rs As DAO.Recordset
    Dim db As DAO.Recordset
    Dim strSQL As String

    ' Find the record that matches the control.
    Me.RecordsetClone.FindFirst "[BridgeID] = " & Me![cboBridgeID]
    Me.Bookmark = Me.RecordsetClone.Bookmark

    Set db = CurrentDb
    ' have access load and run the qry
    strSQL = "Select * from qryBridgePhotos where qry.ID=" & Me!cboBridgeID & ";"

    Set rs = db.OpenRecordset(strSQL)
    If rs.BOF And rs.EOF Then ' nothing to do
    Else
    'On Error Resume Next
    Me![ImageFrame1].Picture = rs.Fields("9798_pht1")
    End If

    End Sub

    Get type mismatch error(13). Look forward to your comments.
    Nb it falls over at set db = Currentdb (= nothing) - why??
    BridgeID is numeric.

  2. #2
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Does this run the first time, but fail after that?
    I notice that you never kill the db or rs variables. Try :
    Code:
        Me![ImageFrame1].Picture = rs.Fields("9798_pht1") 
    End If 
    
    If Not (rs is nothing) Then
        rs.close
        Set rs = nothing
    End If
    
    If Not (db is nothing) Then
        Set db = nothing
    End If
    End Sub

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  3. #3
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Can I point out...

    You are using a combo list right ?

    So why not return the picture path/name in that combo box but make the column width 0...

    Then after update, just grab the info from the column :
    imgPiccy.picture=cboList.column(1)

    Assuming MS Access there, but the principle should be the same for VB. I think the Vb would be using an array hidden on the form or something and the same extra column can be applied.

    Regards

    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

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



Click Here to Expand Forum to Full Width