How do I tell MS Access to look for a Text Box on a Page? (1 Viewer)

Cark

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 13, 2016
Messages
153
I have a Form which has 2 Tabs which contain separate aspects of information that are related to the same PartID.

What I am trying to do is to come up with a method so that if there is a Description entered into the Reliability Tab (and the Decription Part ID value on the Reliability Tab has a value) then the Text Box on the General Information Tab called Reliability Programme Present?: should show YES.

The way the user would input the data would be:
  1. Enter the Part ID at the top e.g 7155
  2. On the General Information Tab the user would enter a Description e.g TEST 7155
  3. The user would then go to the Reliability Tab and then enter a Description e.g TEST RELIABILITY.
  4. The user would then go back to the General Information Tab and should be able to see the "Reliability Programme Present?:" Box filled with YES.

I have been fumbling around and something like the code below should work, but it gives me issues whenever I click on the Reliability Tab as Me.ReliabilityProgrammePresent is only present on the General Information Tab and not on the Reliability Tab.

Code:
    If Parent.PartID = Me.PartID Then
    
        Me.ReliabilityProgrammePresent = "YES"
        
    End If

Any way to resolve this? What about the idea of identifying whether Me.ReliabilityProgrammePresent is on the Tab or not?

I am not too familiar with Page properties.

Happy to talk it through if there are any questions.
 

Attachments

  • Capture.PNG
    Capture.PNG
    66.5 KB · Views: 73
  • ReliabilityProgrammeIdentifier.accdb
    1 MB · Views: 84

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,169
You do it on the Change event of the tab control:
Code:
Private Sub TabCtl12_Change()
    
    If Me.TabCtl12.Value = 0 Then
        If Trim(Me.FrmSubReliability.Form!Description & "") = "TEST RELIABILITY" And _
                (Me.FrmSubCoverInformation.Form!ReliabilityProgrammePresent & "") <> "YES" Then
            Me.FrmSubCoverInformation.Form!ReliabilityProgrammePresent = "YES"
            
        End If
    End If
End Sub
 

Cark

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 13, 2016
Messages
153
Hi Arnel,

I tried putting your snippet of code, but it did not seem to work.

Also the Description boxes will have different text for each part number so I don't think the code should involve these as hard coded items.

I have a feeling something like "If Parent.PartID = Me.FrmSubReliabilityProgramme.Form!PartID Then" might be useful.

Thoughts?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,169
just add the condition to our expression:
Code:
Private Sub TabCtl12_Change()
    
    If Me.TabCtl12.Value = 0 Then
        ' check if both subform's PartID has value
        ' and that both values are the same.
        ' check also the field Description in the subform
        ' on Page "Reliability" has some text in it
        '
        ' if all are true, then finally check if the
        ' ReliabilityProgrammePresent has already been set
        ' to Yes. If not set it, otherwise, ignore.
        '
        If Nz(Me.FrmSubReliability.Form!PartID, 0) <> 0 And _
           Nz(Me.FrmSubCoverInformation.Form!PartID, 0) <> 0 And _
           Nz(Me.FrmSubReliability.Form!PartID, 0) = _
           Nz(Me.FrmSubCoverInformation.Form!PartID, 0) And _
           Trim(Me.FrmSubReliability.Form!Description & "") <> vbNullString And _
            (Me.FrmSubCoverInformation.Form!ReliabilityProgrammePresent & "") <> "YES" Then
            Me.FrmSubCoverInformation.Form!ReliabilityProgrammePresent = "YES"
            
        End If
    End If
End Sub
 

Cark

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 13, 2016
Messages
153
Hi Arnel,

Can you explain why the Me.FrmSubReliability.Form!PartID part works? Why does it not need to be Me.FrmSubReliabilityProgramme.Form!PartID?

I have another SubForm called FrmSubFinanceProgramme and have tried copying the the fields over to use the following code, but it does not seem to be working:

Code:
        If Nz(Me.FrmSubFinance.Form!PartID, 0) <> 0 And _
           Nz(Me.FrmSubCoverInformation.Form!PartID, 0) <> 0 And _
           Nz(Me.FrmSubFinance.Form!PartID, 0) = _
           Nz(Me.FrmSubCoverInformation.Form!PartID, 0) And _
           Trim(Me.FrmSubFinance.Form!Description & "") <> vbNullString And _
            (Me.FrmSubCoverInformation.Form!FinanceProgrammePresent & "") <> "YES" Then
            Me.FrmSubCoverInformation.Form!FinanceProgrammePresent = "YES"
        End If

Similar to Reliability having a Page/Tab called Reliability, Finance has a Page/Tab called finance.

Let me know if you need further information.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,169
it is simple, both subform's are linked to main form via their PartID field.
therefore both subform must have the same PartID.
 

Cark

Registered User.
Local time
Yesterday, 18:36
Joined
Dec 13, 2016
Messages
153
If the Tab Page Name was something with a space e.g Customer Support would I use Customer_Support or [Customer Support] in the place where Reliability is?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 09:36
Joined
May 7, 2009
Messages
19,169
it doesn't matter the name of the Tab Page.
The subform's are only Hosted by the Pages, BUT, they are member of the Main form.
so you refer then as:

Code:
Me.SubformName.Form!PartID
or simply:
Code:
[SubformName].Form!PartID
Me there refers to the Main form itself.
 

Users who are viewing this thread

Top Bottom