Solved Validating Data in Subform

Weekleyba

Registered User.
Local time
Today, 15:06
Joined
Oct 10, 2013
Messages
593
When opening F_Project form to a specific ProjectID, I have some code to check if 3 fields are populated. If they are populated, then all the other controls that are Enable No, change to Enable Yes. Otherwise the stay with Enable No.
This method works for all the controls that are on the F_Project.
The code is in a On Click event in another form, F_Main. When I click on a project in F_Main, it opens the F_Project where the ProjectID matches and then runs the code for Enabling the controls.
Ok, with that said, I would like to do something similar with a subform on the F_Project. The subform is on the page called Submittals, and the subform is called SubmittalF. I am forcing the user to populate the Date of Submittal field by use of the Before Update event. This works fine. But when I come back to the subform, I need the code to run Enable Yes for the controls.
If tried putting the code in the SubmittalF's OnCurrent, OnGotFocus events but it does not work.
Also tried in the to fire the code below from the page's On Click event. No dice.
(the green highlight is just to indicate that these three field are actually on another subform. It gets populated through a query)

Any ideas how I can make this happen?

1660142702910.png


Here's one of my attempts. This is attempting to fire the code below from the page's On Click event.

1660143753817.png



1660143896981.png
 

Attachments

  • 1660144127683.png
    1660144127683.png
    43.8 KB · Views: 133
Have you tried using the Tab Control's Change event?
 
Thanks guys. That is get me closer to final solution.
The problem now is that the code fires when I click on any tab, causing the msgbox to appear saying you don't have any data in the Date of Submittal field. I only want that to pop up when I click the Submittals tab.
Any ideas on how to make that happen?


1660148086933.png
 
Thanks guys. That is get me closer to final solution.
The problem now is that the code fires when I click on any tab, causing the msgbox to appear saying you don't have any data in the Date of Submittal field. I only want that to pop up when I click the Submittals tab.
Any ideas on how to make that happen?


View attachment 102398
I agree. Amend your code to only run if you're on the right page.
 
This appears to work.
Is this what you were thinking?

Code:
Private Sub TabCtProjects_Change()
   'ValidationOfControl = True when certain fields are not populated
  
   If Forms!F_Project!TabCtProjects.Value = 5 Then
      
        If ValidationOfControl(Forms!F_Project.SubmittalF.Form) = False Then
        
          With Forms!F_Project.SubmittalF.Form
          
           .DateReturned.Enabled = True
           .SubmittalNum.Enabled = True
           .Subject.Enabled = True
           .SpecificationSection.Enabled = True
           .NewSubmittal.Enabled = True
           .Resubmittal.Enabled = True
           .AdditionalInfo.Enabled = True
           .ShopDrawing.Enabled = True
           .Administrative.Enabled = True
           .AsBuilts.Enabled = True
           .Sample.Enabled = True
           .ProductData.Enabled = True
           .OM.Enabled = True
           .cmdAddSubmittal.Enabled = True
           .cmdPreviousSubmittal.Enabled = True
           .cmdNextSubmittal.Enabled = True
           .SubmittalItemSF.Enabled = True
           .NoException.Enabled = True
           .ReviewedasNoted.Enabled = True
           .ReviseandResubmit.Enabled = True
           .RejectedSubmittal.Enabled = True
           .Other.Enabled = True
           .CompleteResubmittal.Enabled = True
           .AdditionalInfoToReturn.Enabled = True
           .SubmittalComments.Enabled = True
           .cmdSubmittalTransmittal.Enabled = True
          
          End With
          
        End If
        
    End If
    
End Sub
 

Users who are viewing this thread

Back
Top Bottom