0

I Have a form with 2 subforms. the Mainform is attached to a table called FrmFilters. From this I have created 2 filter objects, the 1st Filter (Filter1) is a drop list which acts as the Link to Subfrm1, the 2nd Filter (Filter2) is a txt object which is set to = [SubFrm1].[Form]![Prod_Id]. Filter2 is updated on the GotFocus (Event Procedure) of the Prod_Id Field in Subfrm1. Filter2 then acts as a link to Subfrm 2 which pulls up information from the Product Inventory table, included in this is an Unbound Picture Object which links to a external folder of Jpg's depending on the selected product. At this moment this works by clicking on the Picture object which has a Click (Event Procedure) that sets the Me.ImageLink.Picture = Me.ProdImage.text (where the Prodimage is a field within the Product Inventory table).

This works fine, however I would like to automatically update the unbound Picture (ImageLink) in subfrm2 when I cycle through the records in subfrm1. Any help would be much appreciated. thanks in advance.

I have tried using the DoCmd.GotoControl "Subfrm2" which worked in itself (But I did notice an issue with trying to move to next record in subfrm1, as it creates a loop in the got focus instruction)

From here I was intending to use the setvalue Me.ImageLink.Picture = Me.Prod_Image.Text or Forms!Subfrm2!Imagelink.Picture = Forms!Subfrm2!Prod_Image.Text

I have also tried the SetFocus command to go directly to the Imagelink object but couldn't get the code to recognize the form (either by its official name "OrderFrm Product Inventory" or subfrm2)

Private Sub Title_GotFocus() ' Update dbFormTbl Form Filters with active record Prod_Id Link (Flt_Prod_Id) On Error GoTo Title_GotFocus_Err

DoCmd.SetWarnings False
DoCmd.OpenQuery "updQry dbFormTbl Form Filters (Prod_ Id)", acNormal, acEdit
Call UpdateImage
DoCmd.SetWarnings True
Form.Refresh

Title_GotFocus_Exit: Exit Sub

Title_GotFocus_Err: MsgBox Error$ Resume Title_GotFocus_Exit End Sub Private Sub UpdateImage()

Dim db As Database
Dim Sf1 As Recordset
Dim sBookmark As String
Dim Sf1Indx As Integer

Set db = CurrentDb()
Set Sf1 = db.OpenRecordset("tblOrderitems")
sBookmark = Sf1.Bookmark

Sf1Indx = Sf1("Prod_Id")

[Forms]![Order Lookup]![SubFrm2].[Form]!ImageLink.Picture = [Forms]![Order Lookup]![SubFrm2].[Form]!Prod_Image.Text
Sf1.Bookmark = sBookmark

Sf1.Close

End Sub

Andy
  • 1
  • 1
  • New code added to the GotFocus event. this does update the image but the repaint object needs to be added as the Image only changes for record 2 upon moving to record 3. – Andy Mar 23 '23 at 15:20

0 Answers0