Thread: subform has focus?
08-31-12, 13:34 #1Registered User
- Join Date
- Jun 2010
Unanswered: subform has focus?
I have an Invoice info m/f from a select query with 4 different s/f.
The invoice(m/f) is chosen for 1 or more of 4 reasons in which I need these s/f's.......for example: to make a credit or a correction which becomes a many side record of this (1-side) invoice
so any one of these can be used.........and they appear in order of importance.
Since nothing is entered or altered in the (qry) m/f I had a setfocus to the first field of the first s/f...and I would just click away if I was not using that
Private Sub Form_Open
I recently had to add code to 2 of the s/f, including the first one sfADJ, to fill in a numeric value in the record source of the s/f
1st one: Private Sub CMNO_GotFocus()
Me.AACCT = [Forms]![frmINVMF]![tblCust31212.ACCT]
3rd one: Private Sub FINVNO_GotFocus()
Me.FACCT = [Forms]![frmINVMF]![tblCust31212.ACCT]
adding that code made it so when I would open the m/f, the first s/f has focus so a record would be created and the control filled in per my code. I can't have that. I don't always need that s/f.
To try to stop it, I put an unbound text box in the m/f I'm calling holder and setting the focus there so I can choose which s/f I want to go into.
Private Sub Form_Open(Cancel As Integer)
It does trigger, and access is also triggering the 1st s/f event, too. (Not the 3rd) I think it's because access automates itself to s/f's.......and I'm wondering if anyone has a fix for that? Do I have to shield the s/f's behind a tab page or, more simply, can I re-write the GotFocus on the 1st s/f so it only triggers when I need it to ?
The goal is for none of the s/f's to "activate" unless I click into them and start a record, and for neither s/f GotFocus to trigger unless I click into them.
Appreciate everyone assistance!
09-01-12, 14:42 #2Moderator
Provided Answers: 19
- Join Date
- Jun 2005
- Richmond, Virginia USA
What, exactly, is tblCust31212.ACCT? It sounds as if you're trying to populate the Foreign Key on your Subform with the Primary Key from your Main Form; is that what you're doing?
Linq ;0)>Hope this helps!
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
09-04-12, 15:32 #3Registered User
- Join Date
- Jun 2010
Thanks for your response!
Not exactly - a recent change in reporting is causing a need for this s/f to relate to m/f on 2 fields. But they are both foreign keys
I start with a UQ called frmINVMF of INVNO and CIINVNO (these are 2 different types of invoices, from different tables)
then I drop that into a select query to join it on tblCust31212.ACCT (which is customer number)...that is m/f
m/f(query) = FROM tblCust31212 INNER JOIN frmINVMF ON tblCust31212.ACCT = frmINVMF.ACCT
s/f(tblADJ) = tblADJ is related to tblInvoices on INVNO (foreign key/text) which is what I use for master and child links
I went back because I find that I need a report of tblAdj on ACCT from tblCust31212, not INVNO from tblInvoices. I added AACCT to tblAdj and entered the ACCT numbers in the table (foreign key/number) *should this be named the same as it is in tblCust31212 (ACCT)?
So when it comes to using the s/f, the relation to INVNO is okay because this tblADJ record is created through INVNO, but for reporting purposes...it needs to be seen by ACCT.
I don't have any experience with relating on more than 1 field. Maybe that is the problem? telling you the scenario this way made me realize that is what I am doing.
Having used code to fill in controls before, I thought that would be a way to get the info in the table without the user typing.
Is this totally backwards?