Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab Caption Goes Away 1

Status
Not open for further replies.

JeremyNYC

Programmer
Sep 23, 2002
2,688
US
I've got a multi-page subform with a tab control on one of the pages. The code that moves you from page three to page four, which is where the tab is, changes the tab captions according to some information stored in a table. Only it's not working. Actually, it is working, and then it's unworking.

The tab caption starts out "And...". Depending on what's in the table, the caption may get changed to "Or...".

Here's the code that makes the changes, from two different functions:
Code:
Debug.Print "Pre ShowAndNameTags: " & .Pg2.Caption
    If !msfConditions2.Rows <> 1 Then
        .Pg3.Visible = True
        .Pg2.Caption = SetAndOr(1)
    End If
Debug.Print "Post ShowAndNameTags change: " & .Pg2.Caption

=====
Debug.Print "Pre SetAndOr: " & .Pg2.Caption
    If intpage = 0 Then
        intpage = !tabQuery.Value
    End If
    strCaption = IIf(.Controls("fraAndOr" & intpage + 1) = 1, "Or...", "And...")
    !tabQuery.Pages(intpage).Caption = "Test Caption" ' strCaption
Debug.Print "Post SetAndOr: " & .Pg2.Caption

=====

In both cases I've got proper with/end with structures. In both cases I've inserted debug.print statements for testing (including the function name). In the second function I've replaced the value that should be shown with "Test Caption", just for testing purposes.

Here's what shows up in the immediate window:
Pre ShowAndNameTags: And...
Pre SetAndOr: And...
Post SetAndOr: Test Caption
Post ShowAndNameTags change:

This happens whether or not I leave the original strCaption as the value for the caption, and it happens no matter wht strCaption evaluates to.

Does anyone know why the caption would go blank? I've looked around here and on CDMA and other places but not found even a hint of a similar problem anyone had. Any help would be muchly appreciated.

Jeremy Wallace

---
Jeremy Wallace
METRIX Project Coordinator
Fund for the City of New York
 
Code:
Debug.Print "Pre ShowAndNameTags: " & .Pg2.Caption
If !msfConditions2.Rows <> 1 Then
	[b][COLOR=red].Pg3.[/color][/b]Visible = True 
	.Pg2.Caption = [b][COLOR=blue]SetAndOr(1)[/color]
[/b]End If
Just to make sure that(.Pg3.) is not a typo !?
and what is SetAndOr(1) ?

Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
Zameer,

Thanks for checking this out.

No, .pg3. isn't a type: the form is a query-builder wizard, and we only make later tabs visible if the user has added at least one criteria on each of the previous tabs. What's happening here is that the user has just added a criterion on tab 2, so we make the next tab (.pg3), visible and set the caption of the current tab. Which brings us to SetAndOr, which is a function (the second one I snipped from) that sets the caption to either "And..." or "Or...", depending on what the person entered for the criterion on that tab.

Jeremy

---
Jeremy Wallace
METRIX Project Coordinator
Fund for the City of New York
 
Jeremy, one more question. What is
Code:
If !msfConditions2.Rows <> 1 Then
I can't find a control that has a Rows Property. If it is a list/combo box then it should be ListIndex <>-1
I am sure you are not wrong. Still....


Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
Zameer,

That's a Microsoft Grid Control, one of the extra goodies on the toolbar. The first row holds the headings, and is already populated. If it's got more than that, then the user has added at least one criterion on the page. I suppose it could be > 1 instead of <> 1, but I inherited this code, and that part is working...

Jeremy

---
Jeremy Wallace
METRIX Project Coordinator
Fund for the City of New York
 
I would think [tt]SetAndOr()[/tt] would be a function with a string return value, but it looks like your trying to set the caption directly instead. How about doing something like this:
Code:
  .Pg2.Caption = SetAndOr(1, Me!fraAndOr.Value)


Private Function SetAndOr(ByVal intPage As Integer, ByVal intFrameVal As Integer) As String
  Select Case (intPage + intFrameVal)
    Case Is > 1
      SetAndOr = "And..."
    Case Else
      SetAndOr = "Or..."
  End Select
End Function

VBSlammer
redinvader3walking.gif

"You just have to know which screws to turn." - Professor Bob
 
VBSlammer,

Yeeeeeee HAAAAAaaa. Thank you so much for pointing out what I was doing wrong. That's exactly it. I inherited the code from someone else, got hip-deep in it, and just didn't see this for some reason.

This was the only thing on this major project that I just couldn't understand (OK, well we found another one last night, but...), so thank you VERY much for pointing out the flaw in my code.

Jeremy


---
Jeremy Wallace
METRIX Project Coordinator
Fund for the City of New York
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top