URGENT HELP NEEDED : SetFocus subform to subform

Will04

Registered User.
Local time
Today, 15:19
Joined
May 29, 2006
Messages
62
Hi everyone,

I'm working on developing a patient registration system which consists of 6 tables linked by a patient file number.
The data entry form has a main form and 5 subforms. I got no problems moving from the main form to the first subform (frmpaddr), but I'm having some difficulty in moving the focus from one subform to another subform.
In the attached db, I want to :-
Move from workphone of frmpaddr to the first address line in frmtaddr,
Also, to move from Phone No of frmtaddr to name of frmnokdets
Move from last address line of frmnokdets to RefferingPhysician of frmattdocs
Move from Medical Oncologist of frmattdocs to weight of frmclindata

Any assistance will be greatly appreciated

Thanks

Will
 

Attachments

I cannot open zips here

but as a thought are these subforms tied to child tables or is it 1 table with all the info on
if its 1 table then a tab approach might be better (and easier on the eye) if its tables- x 5 then subforms is the right route to go to - and i cannot help
g
 
Hi Gary,

Is there a prob. with the zip file??

There are 6 separate tables linked by the patient file no.

Thanks


Will
 
zip fine - I am at work and cannot download zips over the net
and i will bail out on this - it should not be rocket science

my thoughts on this would be all creating records unique id and using this as the filter onto your 5 other tables

main table unique idno 12345
have this add onto your 5 other tables and apply a filter on your open form tied to this
so
a save option on your main form would add 5 records (1 for each table and these would have your maintable as a referenceno then create your 5 subforms as you want them and now you can use the wizard to open up the forms you require

might not be the best way - but will work

regards and at this point I am bailing out on it cos I cannot download d/base and look at it
 
If you want to ALWAYS be able to tab between the controls on the subforms, you won't want the code on the AfterUpdate event of the control as that will only fire if something is either added or changed. If you want it always then you will have to test on the KeyPress event and set the code to fire if the key pressed is a tab key.

Next, for the first one you want, to reference the subform control, you would type:
Code:
Forms!frmPerson.frmtaddr.Form.Taddr1.SetFocus
 
Hi Bob,

Thanks so much for replying to my post.
I tried your suggestion but it's still not working. The cursor keeps moving from field to field within the form 'frmpaddr'

Here's the code:-

Private Sub PatWorkPh_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 9, 13
Forms!frmPerson.frmtaddr.Form.Taddr1.SetFocus
End Select
End Sub


Any suggestions??


Thanks again.

Will
 
I think you would be better off setting focus to a control within the subform rather than the form.
 
Hi Banana,

Do you mean leave off the reference to the main form? like this

Forms!frmtaddr.Form.Taddr1.SetFocus

I tried that and it didn't work...

Thanks

Will
 
Hi Banana,

Thanks for the advice and the link.

Did you look at the Db that I attached?

I have placed the following code in the AfterUpdate and KeyPress property of the field Patworkphone which is in the frmpaddr form.


Me!frmtaddr.Form!Taddr1.SetFocus

The code is supposed to set the focus to taddr1 which is the first field of the form 'frmtaddr'

For some reason, it is not doing that, rather it is just being cycled through all the fields in the frmpaddr form.

I just can't figure out why its not working..

Will
 
sorry for the URGENT in Title...prior user's thread ..I dont know how to delete it.

I have one form, three separate subforms all linked as Master/Child from Main form.
I have been unable to get the tab to move from 1st subform to second one. I have used all versions of code provided above to no avail...
Can someone take a quick gander at this and advise why or how to fix?? formDocs is the mainform and the tabbing from subformCases.CaseState to subformPeople.LastName is an example of the problem...
Thank you in advance.
 

Attachments

Last edited:
zip fine - I am at work and cannot download zips over the net
and i will bail out on this - it should not be rocket science

my thoughts on this would be all creating records unique id and using this as the filter onto your 5 other tables

main table unique idno 12345
have this add onto your 5 other tables and apply a filter on your open form tied to this
so
a save option on your main form would add 5 records (1 for each table and these would have your maintable as a referenceno then create your 5 subforms as you want them and now you can use the wizard to open up the forms you require

might not be the best way - but will work

regards and at this point I am bailing out on it cos I cannot download d/base and look at it
A little off topic but you can have people send or post you a zip file with another extension like._ip. When you get it change the extension back to .zip and away you go.
 
Will & Nexshark-

I'm afraid I'm a dinosaur toting along on Access 2003, so you'll need to ask someone else or downgrade the version.

As for the SetFocus, I had similar issue.

To get this to work, you need to make a progression of setfocus. I don't know but that's what I did... :rolleyes:

So say you're on a mainform and want to setfocus to a control on subform.

Code:
With Me.Form!MySubform
   !SetFocus
   !ControlBox.SetFocus
End With

Consult the reference I linked earlier for other situation where you have cursor in different places.

Notice that you need to first set focus on form itself then on the control next. Therefore, if you have two subforms nested in a form, you'd setfocus to 1. MainForm, 2. MainForm's Subform control 3. Subform itself 4. Subform's subform control 5. 2nd subform's form 6. 2nd subform's control.

It's possible that #2 and #4 is unnecessary as I'm coming off the top of my head, but I don't feel like testing this right now.

HTH.
 
I don't mean to be a pain, but can someone with Access2007 take a look at this, as I have tried every string of code I can find, and cannot tab from 1st subform to next one..

Please:o ?
 
Found manual solution, still looking to automate

I have found one solution now. Couldn't find it thru advvanced search on the forums, but upon Googling it it brought me onto this forum to the following thread:
http://www.access-programmers.co.uk/forums/showthread.php?t=15798

Simply put, Ctrl and tab will take me from one subform, last field, to next subform, first tab...
But I am still looking for wys to automate this process. If anyone can help. I have tried all manner of code snippets I have found, and reviewed the resource guide Banana provided and tried all variations of that...

Again. any help...??
 
Good to know you're trying hard with the searching. Googling the site is a good way to go; I do that now and then.

As for looking at your database, why don't you go and try downgrade it to 2003. If you didn't use anything that is Acces2007 specific, it should work. Access has the version conversion somewhere in the ribbon or from Mircosoft button on upper left corner.
 
I don't know who's actually downloaded Will's db and looked at it, but to be brutally honest, this db design is just plain nuts! There's a table for the patient's name, a table for their place of birth, a table for their sex, a table for ethnicity, a table for their permanent address, a table for their temporary address, a table for their next of kin, a table for their attending physician, and a table for their clinical details! Much of this needs to be in a single table, possible with tabbed pages. This would alleviate much of the problems currently being experienced.
 
Couple of answers...Banana, I tried to convert down to 2003...unfortunately I am using multivalue fields (and apparently something else cuz I removed them and it still wont).

Missingling...I just wrote on the end of Will's thread because his problem is the same. I, respectfully, have no interest in his table designs...just in answers to the same questions he posed. I would be extremely interested if you told me MY table designs were nuts, as I really need any guidance I can get.
Having said that, I think I found a snippet of code that has worked in my first test...I will be employing it in several places then will report back.
Here is the threead from whence it came...http://www.access-programmers.co.uk/forums/showthread.php?t=40911 Down a ways is the oldsoftboss post including the progressive SetFocus.
I do appreciate all of the input... I am as new to this as one can be and am trying to put together something that is more complex than my little brain can wrap around... Thanks again Banana and missingling
 
Sorry, nexshark, I'm running Access 2000, and can't download your db! I never buy a Micro$oft product until it's had its second birthday! Still remember the patches they issued for the patches they issued for Windows98! Access 2007 is such a departure from all the previous versions that you need to extra careful, as you were here, to let everyone know that you're runnng it when you post questions!

Good Luck!

Linq
 
At least what you could do is a screen dump of your database's relationship and the form itself.

If you don't know how to do a screen dump, it's very easy. If you have 117-key keyboard, there's a key that says "Print Screen" (actually, PRNT SCN or some kind of abberviation), two or three keys right of the F16 key. When you have the window where you need to display relationship or form, press that key, open a program named MS Paint (in Accesories folder), paste it, crop it down a bit then save it as a jpg. You can then upload the picture using tinypic.com or photobucket.com then post here enclosing the image's address in [IMG][/IMG] tags.

HTH.
 

Users who are viewing this thread

Back
Top Bottom