Tabbed subforms

Bruce75

Psychologist
Local time
Today, 09:54
Joined
Sep 29, 2004
Messages
46
Hi

I have a form with three subforms. The three subforms are on 3 different tabs.

I am trying to get it so that when the user enters data on a particular subform, focus is set to another control a different subform on a different page.

I have got this so far:

Forms!frm_patientdetails.SetFocus
Forms!frm_patientdetails!patientID.SetFocus
DoCmd.GoToPage 2

Why is this not working? I have googled myself blind, but being a novice have probably missed something important.

thanks

Bruce
 
Okay, here you go. :
Code:
Me.YourTabControlNameHere.Pages(n).SetFocus
Me.YourSubformCONTAINERNAME.Form.YourTextboxNameHere.SetFocus

Pages(n) the n is the number of the tab (not zero based) and you can use the name of the page instead by using Pages("YourPagenameHere")
 
And this might help you with how to use subform syntax:

1. When you are dealing with subforms, you are actually dealing with two parts - the subform CONTAINER (that which houses the subform on the main form) and the subform itself.

2. The subform and subform container can be named the same, but are not necessarily so. You need to check before writing the code. If they are the same then it simplifies things but it doesn't really matter if it is, or isn't, because you just have to refer to the container.

3. When you are doing things, like setting the recordsource on the subform, you are not really requerying the container, as it doesn't have a requery method, but the subform itself does. So, when you are referring to a property, or method, on the actual subform (not the container), you need to have the subform container name and then .Form. between the container name and the method, or property, so Access knows you want to refer to the form's method or property and not the container's method or property.
 
thanks for your response Bob

I get what you are saying about the different between subform and the container it is in.

However, I still can't get it to work.

Me.tabctrl1.Pages("Waiting Lists").SetFocus
Me.sf_jun_waitinglist.Form.startdate.SetFocus

the code stops on tabctrl1 saying method or data cannot be found. tabctrl1 is, however, the name of my tab control.

Perhaps if I gave a little more information it may be helpful, because maybe I have described my situation poorly or incorrectly.

The user is on page 4 of the tab control, containing a datasheet view subform. When they enter data in one of columns, I want them to be re-directed to another subform (also in datasheet view), on page 2 of the tab control, to a specific control on this second subform. To this end, I have put the code in the beforeupdate property of the first subform (on page 4).

As always, I greatly appeciate any help given.

Cheers

Bruce
 
thanks for your response Bob

I get what you are saying about the different between subform and the container it is in.

However, I still can't get it to work.

Me.tabctrl1.Pages("Waiting Lists").SetFocus
Me.sf_jun_waitinglist.Form.startdate.SetFocus

the code stops on tabctrl1 saying method or data cannot be found. tabctrl1 is, however, the name of my tab control.

Perhaps if I gave a little more information it may be helpful, because maybe I have described my situation poorly or incorrectly.

The user is on page 4 of the tab control, containing a datasheet view subform. When they enter data in one of columns, I want them to be re-directed to another subform (also in datasheet view), on page 2 of the tab control, to a specific control on this second subform. To this end, I have put the code in the beforeupdate property of the first subform (on page 4).

As always, I greatly appeciate any help given.

Cheers

Bruce

two things -

1. You probably should have the code in the AFTER UPDATE event of the other form as it could screw things up trying to move before the form has updated.

2. Looking at your naming, I am concerned. Does sf_jun_waitinglist mean that you have 11 other forms (jul_waitinglist, aug_waitinglist, etc.)? If so, your design is flawed and needs to be re-examined.

As for your control, if you want to post your database go to Tools > Database Utilities > Compact and Repair to compact it first, and then zip it with WinZip or something like it. The final zipped file size needs to be 393KB or less. If you can't get it that small I can PM you with an email address to send it to me so I can take a look.
 
Thanks Bob - you are exceptionally generous with your time.

Firstly, I will try it in the After Update event

Secondly, the form is name jun... which is short for junction. So it sf (subform) jun (jun) waitinglist. When I began this, I named them so because it was based on a junction table. But, I had problems with populating two foreign keys, and after looking through this forum, I based the subforms on a query but retained the naming..

Finally, please find my database zipped and attached.

Again, thank you very much.

Edit: Just for reassurance, all the patient and health professional data is fictional.
 
Last edited:
Can you tell me which form and controls I should be looking at?
 
Sure:

the main form is frm_patientdetails (tab control is tabctrl1)
the subforms are sf_jun_waitinglist (control is offdate), sf_jun_individualevent (control is startdate).

I would like it so that when the user enters an startdate on sf_jun_waitinglist (i.e. when someone starts a therapy) they are redirected to the appropriate offdate on sf_jun_waitinglist (when someone is taken off the waiting list).

Thanks yet again.
 
I would like it so that when the user enters an startdate on sf_jun_waitinglist (i.e. when someone starts a therapy) they are redirected to the appropriate offdate on sf_jun_waitinglist (when someone is taken off the waiting list).
I'm not sure I am understanding that statement. Are you saying that if you put someone on a waiting list, that it should search through all of the available records to see if there is a date that exists in there where someone ELSE was, or is going to be, taken off of the waiting list?
 
No, sorry, I don't think I have been very clear.
Short answer:
I am trying to get it so, if the user enters a start date for a therapy, they are re-directed to the end date of the waiting list subform, or just that the tab page that the waiting list subform is on, is opened up.

Long Answer:
I have one table called waiting lists, and two tables called individual treatments and group treatments. It may have been better to have designed the database with one treatments table, but I figured because a single group may have several patients but have the same start and end date with multiple potential therapists, whilst an individual treatment would have an individual start and end date and a specific therapist, it might be economical to have this data on two different tables (so that the user doesn't have to enter the same start and end date for, say, group number 8, for 10 patients). This design decision, I have subsequently realised, means that it is difficult to automatically take somebody off a waiting list when they start a therapy, as the types of therapy that somebody might be waiting for, includes both individual and group therapies, is on one table, whilst individual and group treatments are on two separate tables. My concern is that when a temp uses the database they enter a start date for a therapy but do not remove the person from the waiting list.

I thought that a way round this might be, when somebody enters a start date for a therapy, whether it be an individual or group therapy, a message box appears reminding them to take the person off the waiting list, and they are redirected to the tabbed subform on the frm_patientdetails that has the waiting list data. I thought that this might help ensure that the database is correctly kept up to date. Hence my original question about using Setfocus and switching focus to a tabbed subform.

As you may be able to tell, my training is not in computers, but I am trying to do my best to develop a database that may help to track our patient's journey through our service, and thereby provide a better, more efficient service.

A further consideration when designing this database was that it is an evolving service - hence I needed to allow staff to add new treatments if I leave. This function had to be within the user interface and require no knowledge of Access, as it is likely that any successor to me will have even less knowledge of Access than I do.

Thanks for any help,

Bruce
 
Last edited:

Users who are viewing this thread

Back
Top Bottom