set focus to subform but do not activate

Davros

Registered User.
Local time
Today, 08:00
Joined
Sep 9, 2005
Messages
131
i won't go into details except i am doing databases for cemeteries - very complicated
example
i have come across two people who have the same name, date of death, buried in the same grave on the same day but are not related and must have seperate records!!
my main table has 6 primary keys. [even then i have 2 duplicates who are not related]
anyway one of the problems is this
i have a main form with 2 subforms. the main form is unbounded. i need to copy information from 1 of 4 queries run by the main form [QBF] to one of the subforms. i don't know which query untill i view the data.
when i know which one, i press a command button which copies the information to one of the subforms. when i repeat the actions above instead on the new query data going into a new record on the subform it overwrites the existing data instead of pasting it into a new record.
i have tried setfocus command - this works only if i click on the subform and activate it [this defeats the object of the command as i might just as well click in a new record box on the subform].
in essence i do not need to activate this subform at all. i just need to check if a record exists and if it does goto a new record [again this works only if i physically click on the form]
any ideas how i can force the cursor to goto a new record without physically clicking on the subform??

thanks
 
a. I would simply do all this with an autonumber pk
b. The grave thing is bizarre :eek:
 
yeah - thought about that but not sure if it would work and
yes
it is bizzarre
trouble is as i am checking each grave for health and safety reasons i find that the data in the burial books and the data 'on the ground' , in most cases, does not match and as i'm dealing with relatives of the desceased its a very sensitive issue and i must get it right!
 
By the sheer definition of set focus, you can't set the focus to a subform and not have it activated. Plus, the only way you can actually set focus to the subform is to set the focus on a control within that subform, as you're finding out you can't just set focus on the subform control as it really means nothing to Access at run-time.

If you need to find out if something exists, you can do a Dlookup using a key identifier from the main form.
 
You can't add the new record with out giving the subform focus. The below code will set focus to a subform name frmSubInsuranceLinse on a main form named frmSetup and add a new record.

Forms!frmSetup!frmSubInsuranceLines.SetFocus
DoCmd.GoToRecord , , acNewRec

You could always set focus to another control after the record is added.
 
thanks for the reply
i tried the above code keithG but it did not work. i can only setfocus when i click on the subform, then the control that i have setfocus to becomes 'live' and the cursor goes to a new record.
in which case why don't i just click in the new record itself which is what i do not want to do bacause i have no need to physically activate the form - only to check that the data is present after my code has ran.
thanks anyway
 
Why not use a popup form formatted as a datasheet, instead of the subform? You can leave the exit button active. That way you can scroll or search the data without changing anything on your main form and then close the popup when you're finished.
 

Users who are viewing this thread

Back
Top Bottom