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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using a page control to give the user two different forms

Status
Not open for further replies.

hallm

Programmer
Jun 11, 2000
159
US
I've got a page control that is on my form. The first page is the form to add child records to my form and the second page is a graphic and an add record button. I'm wanting the 2nd page to be displayed when there are no child records for the currently displayed parent record. If a child record exists it will display the first page.

What is the best way or method to detect whether a record exists?

 
the most reliable way would be something like:
Code:
go top in "ChildTable"
If EOF("ChildTable")
     *!* No Record Exists
     Thisform.PageFrame1.ActivatePage = 2
endif


boyd.gif

 
Where is the best place to fire this code. It's not working, but not giving any error either. So it's probably a timing issue. Here's the code:

GO TOP IN "avoid"
IF EOF("avoid")
ThisForm.MainPageFrame.PatientInfo.avoidabledaysPageFrame.ActivatePage = 2
&& I've also used .ActivatePage = AvoidDaysNoData
ENDIF


I also tried the following code that I combined from your code and Microsofts sample code.

GO TOP IN "avoid"
IF EOF("avoid")
ThisForm.MainPageFrame.PatientInfo.avoidabledaysPageFrame.AvoidDaysNoData.ZOrder
ENDIF

I don't get any errors with that but it still doesn't display the correct page frame.
 
Where is the best place to fire this code. It's not working, but not giving any error either. So it's probably a timing issue. Here's the code:

GO TOP IN "avoid"
IF EOF("avoid")
ThisForm.MainPageFrame.PatientInfo.avoidabledaysPageFrame.ActivatePage = 2
&& I've also used .ActivatePage = AvoidDaysNoData
ENDIF


I also tried the following code that I combined from your code and Microsofts sample code.

GO TOP IN "avoid"
IF EOF("avoid")
ThisForm.MainPageFrame.PatientInfo.avoidabledaysPageFrame.AvoidDaysNoData.ZOrder
ENDIF

I don't get any errors with that but it still doesn't display the correct page frame.
 
I'd need more information...

What event are you putting the code into now. When does the child table get populated with records? Is there a relationship between the child table and a parent table? Have you stepped through the code to find out which part isn't working, and if so was it the EOF() that was returning false or is setting the activepage property the problem? Any other information that you feel might be pertinent to your problem should also be included.

boyd.gif

 
Hi hallm,

I'd say skip the "GO TOP".

If you have a parent/child relation set between the tables, EOF("child") will be true if no record matches that relation.

But with GO TOP, Eof() would only be true if there is really no (none, nada, nothing, niente) record in table "child", not even one for another parent record, but that is not really what you wanted, right?

And maybe you should put that code in the afterrowcolchange event of the grid showing the parent table.

Bye, Olaf.
 
...and you must set the ActivePage property, there is no ActivatePage property...

Bye, Olaf.
 
It's somewhat working after removing go top.

When I first startup the form and select a person that has a child it will correctly display the child. But once I change to a record that does not have a child it will change to my page 2 screen. But will not change back when I go to someone else who has a child record. It doesn't appear to be firing when I need it to.

 
hallm,

Where did you put the code? What are you using for code to switch back to the first page of your pageframe? Did you try putting the code into the afterrowcolchange like OlafDoschke suggested?

Code:
IF EOF("avoid")
     ThisForm.MainPageFrame.PatientInfo.avoidabledaysPageFrame.ActivePage = 2
else
     ThisForm.MainPageFrame.PatientInfo.avoidabledaysPageFrame.ActivePage = 1
ENDIF


boyd.gif

 
Hi hallm,

Well, yes, there also must be code to set page1 to be the active page again, if a parent record has child records...

Bye, Olaf.
 
That's what it was. Thanks, it's working fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top