Solved Sub Form OnLoad Modify Field Formatting (1 Viewer)

LGDGlen

Member
Local time
Today, 08:41
Joined
Jun 29, 2021
Messages
229
Hi All

I have a form that is currently linked to the main form as a pop up form but the users would like to move it from a pop up into the form it pops up from.

So i have created a subform version of the pop up and added it to the main form. All good ...... but......

When the pop up form displayed it had 2 control fields that determined "OnLoad" what parts of the form would be enabled/disabled etc

As part of a subform is there a way to check these 2 fields on load as right now when i check them they are both "Null" on load but once loaded display the values. Currently I have the following VBA in the OnLoad:

Code:
    Dim lngBlack As Long
    lngBlack = RGB(0, 0, 0)

    Debug.Print "Form_Load:"; Me.freight_type, Me.txtchklstregion

    Select Case Me.freight_type
        Case "Air"
            Me.cons_chklst_awb.Enabled = True
            Me.chklst_awb_Label.ForeColor = lngBlack
        Case "Land"
            If Me.txtchklstregion <> "EU" Then
                Me.cons_chklst_phyto.Enabled = True
                Me.chklst_phyto_Label.ForeColor = lngBlack
                Me.cons_chklst_eur.Enabled = True
                Me.chklst_eur_Label.ForeColor = lngBlack
            End If
            Me.cons_chklst_cmr.Enabled = True
            Me.chklst_cmr_Label.ForeColor = lngBlack
        Case "Sea"
            Me.cons_chklst_lading.Enabled = True
            Me.cons_chklst_dhl_conf.Enabled = True
            Me.cons_chklst_dhl_track.Enabled = True
            Me.chklst_lading_Label.ForeColor = lngBlack
            Me.chklst_dhlc_Label.ForeColor = lngBlack
            Me.chklst_dhlt_Label.ForeColor = lngBlack
    End Select

The 2 control fields are Me.freight_type and Me.txtchklstregion

Hope this makes sense, I just want to enable some checkboxes and make the corresponding labels highlighted instead of greyed out

Thanks in advance

Glen
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 08:41
Joined
Jul 9, 2003
Messages
16,282
Try calling your code from the subForm on current event...
 

LGDGlen

Member
Local time
Today, 08:41
Joined
Jun 29, 2021
Messages
229
@Gasman thank you, that web page i've been to before and helps with getting to controls on sub forms etc but not sure (unless i've misread something) describes the event trigger order and when data from a record populates fields on sub forms etc

@Uncle Gizmo adding my code to the current event worked, strangely the current event triggers 3 times when the form loads, the final time though the values are present and i can enable/disable as required

appreciate all the responses though i will definitely bookmark the pages @Gasman as it is useful and usually something that is in distant memory and sometimes forgotten
 

Gasman

Enthusiastic Amateur
Local time
Today, 08:41
Joined
Sep 21, 2011
Messages
14,299
Did you try and walk through the code?
Subforms load before mainform, so you could try the load of the main form and adjust the syntax to suit?
 

Users who are viewing this thread

Top Bottom