Tab Page Visible/Not Visible Not Displaying Correctly? (1 Viewer)

Oreynolds

Member
Local time
Today, 21:43
Joined
Apr 11, 2020
Messages
157
Hi,

I have a tab on a form with 7 pages. I have a need to hide on of the tabs depednent on whether a field is Null and if not based on its value. The tab I want to hide contains about 15 normal bound fields and 1 subform. The code to hide the tab page works fine and is as follows:

Code:
'Show/Hide Order Submission Tab
If IsNull(Me.txtOrderNumber) Then
Me.tabQuotes.Pages(5).Visible = False
Me.tabQuotes.Pages(0).SetFocus
ElseIf Left(Me.txtWorksOrderNumber, 1) = "J" Then
Me.tabQuotes.Pages(5).Visible = True
Me.tabQuotes.Pages(0).SetFocus
End If

The problem I have is when navigating between records on the main form. Although the tab page does change between hidden and visible as you scroll through records the tab itself doesn't properly disappear - the tab text at the top goes and you can't select it but your left with an empty grey tab as per following images:

Am I doing something wrong or is there a workaround? If you subsequently then click on one of the other live Tab pages it does then hide properly but not until you do so?

Any ideas would be appreciated!

NOT HIDDEN:

1590132099380.png


HIDDEN BUT JUST NOT PROPERLY??:

1590132161947.png
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 05:43
Joined
May 7, 2009
Messages
19,169
something is not right.
create new form with tab control.
does it behave the same?
 

June7

AWF VIP
Local time
Today, 13:43
Joined
Mar 9, 2014
Messages
5,423
I have similar code. Difference is I don't reference the tab control name, just the page name. Example:

Me.pge1.Visible = False

It hides and unhides properly while scrolling main form. I also tested with index reference which does require referencing tab control name and that also works. Appears I cannot replicate this issue.

Code is testing two fields txtOrderNumber and txtWorksOrderNumber - is that correct and not a typo?
 
Last edited:

Oreynolds

Member
Local time
Today, 21:43
Joined
Apr 11, 2020
Messages
157
something is not right.
create new form with tab control.
does it behave the same?

Thanks for this.

I have created new from, added tab and required controls and the On Current code and YES it works correctly!

I then deleted all other code on the Current event except the part relating to hiding the tab page and it now works so something else in the current code must be upsetting it although there is nothing else in it relating to the Tab which is strange??

Any thoughts or is it just now trial and error deleting sections of code?
 

Oreynolds

Member
Local time
Today, 21:43
Joined
Apr 11, 2020
Messages
157
I have similar code. Difference is I don't reference the tab control name, just the page name. Example:

Me.pge1.Visible = False

It hides and unhides properly while scrolling main form. I also tested with index reference which does require referencing tab control name and that also works. Appears I cannot replicate this issue.

Could simplify code - reduce 7 lines to 2:

Me.Page6.Visible = Left(Nz(Me.txtWorksOrderNumber, "Z"), 1) = "J"
Me.Page1.SetFocus

Thanks, I'll try this
 

Oreynolds

Member
Local time
Today, 21:43
Joined
Apr 11, 2020
Messages
157
OK, so with some trial and error commenting out section of the On Current code I have identified the conflict which relates to when a record is locked.

I use the following code to lock the record:

Code:
'Lock Record
If Me.QuoteLock = 1 Then
Me.AllowEdits = False
Me.Quotes_Subform.Form.ProductID.Locked = True
Me.Quotes_Subform.Form.Quantity.Locked = True
Me.Quotes_Subform.Form.Cost_to_Us.Locked = True
Me.Quotes_Subform.Form.UnitPrice.Locked = True
Me.Quotes_Subform.Form.Discount.Locked = True
Me.Quotes_Subform.Form.CategoryID.Locked = True
Me.Quotes_Subform.Form.NumberInstallPoints.Locked = True
Me.Quotes_Subform.Form.NumberAddresses.Locked = True
Me.Quotes_Subform2.Enabled = False
Forms!Quotes.Refresh
Else
Me.AllowEdits = True
Me.Quotes_Subform.Form.ProductID.Locked = False
Me.Quotes_Subform.Form.Quantity.Locked = False
Me.Quotes_Subform.Form.Cost_to_Us.Locked = False
Me.Quotes_Subform.Form.UnitPrice.Locked = False
Me.Quotes_Subform.Form.Discount.Locked = False
Me.Quotes_Subform.Form.CategoryID.Locked = False
Me.Quotes_Subform.Form.NumberInstallPoints.Locked = False
Me.Quotes_Subform.Form.NumberAddresses.Locked = False
Me.Quotes_Subform2.Enabled = True
End If

As soon as I comment the above out and the Record is no longer locked the Tab page hides and appears correctly. Is there any way around this?
 

June7

AWF VIP
Local time
Today, 13:43
Joined
Mar 9, 2014
Messages
5,423
Did some more testing. Still cannot replicate. If you want to provide db for analysis, follow instructions at bottom of my post.

I edited my previous post.
 

Minty

AWF VIP
Local time
Today, 21:43
Joined
Jul 26, 2013
Messages
10,355
Try removing the subform enable/disable. I suspect it's causing some weird side effect.
In fact, if you are disabling edits, I can't see the point in locking the controls?
 

Oreynolds

Member
Local time
Today, 21:43
Joined
Apr 11, 2020
Messages
157
Did some more testing. Still cannot replicate. If you want to provide db for analysis, follow instructions at bottom of my post.

I edited my previous post.

Thanks
Did some more testing. Still cannot replicate. If you want to provide db for analysis, follow instructions at bottom of my post.

I edited my previous post.

Thanks for your offer of help, please see attached DB
 

Attachments

  • SFA Order User - SHARE.zip
    3 MB · Views: 153

June7

AWF VIP
Local time
Today, 13:43
Joined
Mar 9, 2014
Messages
5,423
You did not include general code modules so there are a lot of errors for undefined custom functions. Also, some errors for control names that don't exist.

I created a new form (Quotes2) and included only Current event code. Tab hides properly when navigating. So issue may be with some other procedure behind this form causing conflict or original form has corruption that cannot be fixed.
 
Last edited:

Oreynolds

Member
Local time
Today, 21:43
Joined
Apr 11, 2020
Messages
157
You did not include general code modules so there are a lot of errors for undefined custom functions. Also, some errors for control names that don't exist.

I created a new form (Quotes2) and included only Current event code. Tab hides properly when navigating. So issue may be with some other procedure behind this form causing conflict or original form has corruption that cannot be fixed.

Thanks everyone. I solved this in the end. All it was was there was a 'Forms!Quotes.Refresh' once side of the IF and not the other. I broke it down through elimination in the end line by line and as soon as this was put in it stopped the issue! Always the simple things!
 

Users who are viewing this thread

Top Bottom