Referring to field on sub form

G

Guest

I am trying to refer to a ProjectID field on a subform, where frmProject is
the main form (header) and frmProjectIssue is the subform (detail).

I'm trying to set the focus back to the ProjectID field if it does not
validate correctly.

I am doing it in the AfterUpdate of the field. I can't do it in the Exit
event cuz that causes it to display my msgBox numerous times while the form
loads and while the form closes. That's what I had before and now I am
trying to fix it.

So, I backed up to AfterUpdate.

Halp.

Discussion:
There is a field called ProjectID in both the main form and the sub form.
(yes, this is because they want to show all related family of projects in
the detail form, whenever any one of the family is asked to display in the
header).

Anyway, I have tried:
Forms!frmProject!frmProjectIssue!ProjectID.SetFocus
and
Forms!frmProjectIssue!ProjectID.SetFocus

I am still confuzed about "!" and ".", even though I have read it numerous
times. Doesn't always seem to work for me.
 
G

Guest

Set the focus to the subform first and then set the focus to the control. Eg.:
Forms!frmProject!frmProjectIssue.SetFocus
Forms!frmProject!frmProjectIssue!ProjectID.SetFocus

TomU
 
D

DebbieG

Have you tried BeforeUpdate?

If you are in the Main form you need to set focus on the subform object
first, then the object in the subform:

me.frmProjectIssue.setfocus
me!frmProjectIssue.form!ProjectID.setfocus

If you are in the subform you can just

me.ProjectID.setfocus

HTH,
Debbie


|I am trying to refer to a ProjectID field on a subform, where frmProject is
| the main form (header) and frmProjectIssue is the subform (detail).
|
| I'm trying to set the focus back to the ProjectID field if it does not
| validate correctly.
|
| I am doing it in the AfterUpdate of the field. I can't do it in the Exit
| event cuz that causes it to display my msgBox numerous times while the
form
| loads and while the form closes. That's what I had before and now I am
| trying to fix it.
|
| So, I backed up to AfterUpdate.
|
| Halp.
|
| Discussion:
| There is a field called ProjectID in both the main form and the sub form.
| (yes, this is because they want to show all related family of projects in
| the detail form, whenever any one of the family is asked to display in the
| header).
|
| Anyway, I have tried:
| Forms!frmProject!frmProjectIssue!ProjectID.SetFocus
| and
| Forms!frmProjectIssue!ProjectID.SetFocus
|
| I am still confuzed about "!" and ".", even though I have read it numerous
| times. Doesn't always seem to work for me.
| --
| MichaelM
 
G

Guest

Debbie and Tom,

Thanks for the setfocus to the subform first. I haven't done that before.
But, this -is- taking place when the user tabs out of the ProjectID field
-in- the subform, and the Me. did not work before. I will try both. Thanks.

MichaelM
 
G

Guest

Debbie and Tom,

Nope. The referral to the subform, ProjectID field does not work. The VBA
fill does not show the field, and I get an error about the variable or object
not existing.

I am using BeforeUpdate, which I can Cancel if the validation fails, but I
still have to refer to the main form and subform controls.

I only want to validate the subform, ProjectID field, if the main form's
(header's) NO ISSUES check box (chkNoIssue) value is false.

When I try to setfocus back up the the main form, Checkbox control, to check
its value, it doesn't recognize that either.

MichaelM
 
G

Guest

Regarding those lines, it says it can't find the -field-
frmProjectIssue!ProjectID, which is the sub -form-.

Halp.

MichaelM
 
D

DebbieG

Did you get this figured out?

Not quite sure what you're really wanting but I'll guess:

if me.parent!chkNoIssue = 0 then 'false
whatever you're wanting to validate
elseif me.parent!chkNoIssue = -1 then 'true
whatever you want to do, if anything
end if


| Debbie and Tom,
|
| Nope. The referral to the subform, ProjectID field does not work. The
VBA
| fill does not show the field, and I get an error about the variable or
object
| not existing.
|
| I am using BeforeUpdate, which I can Cancel if the validation fails, but I
| still have to refer to the main form and subform controls.
|
| I only want to validate the subform, ProjectID field, if the main form's
| (header's) NO ISSUES check box (chkNoIssue) value is false.
|
| When I try to setfocus back up the the main form, Checkbox control, to
check
| its value, it doesn't recognize that either.
|
| MichaelM
|
| "DebbieG" wrote:
|
| > Have you tried BeforeUpdate?
| >
| > If you are in the Main form you need to set focus on the subform object
| > first, then the object in the subform:
| >
| > me.frmProjectIssue.setfocus
| > me!frmProjectIssue.form!ProjectID.setfocus
| >
| > If you are in the subform you can just
| >
| > me.ProjectID.setfocus
| >
| > HTH,
| > Debbie
| >
| >
message
| > | > |I am trying to refer to a ProjectID field on a subform, where
frmProject is
| > | the main form (header) and frmProjectIssue is the subform (detail).
| > |
| > | I'm trying to set the focus back to the ProjectID field if it does not
| > | validate correctly.
| > |
| > | I am doing it in the AfterUpdate of the field. I can't do it in the
Exit
| > | event cuz that causes it to display my msgBox numerous times while the
| > form
| > | loads and while the form closes. That's what I had before and now I
am
| > | trying to fix it.
| > |
| > | So, I backed up to AfterUpdate.
| > |
| > | Halp.
| > |
| > | Discussion:
| > | There is a field called ProjectID in both the main form and the sub
form.
| > | (yes, this is because they want to show all related family of projects
in
| > | the detail form, whenever any one of the family is asked to display in
the
| > | header).
| > |
| > | Anyway, I have tried:
| > | Forms!frmProject!frmProjectIssue!ProjectID.SetFocus
| > | and
| > | Forms!frmProjectIssue!ProjectID.SetFocus
| > |
| > | I am still confuzed about "!" and ".", even though I have read it
numerous
| > | times. Doesn't always seem to work for me.
| > | --
| > | MichaelM
| >
| >
 
G

Guest

Hi Debbie,

I did 'get it working' and yes, I do think that referring back up to the
parent with your below code will work. Thanks for sticking with me. I'll
get back if I have any trouble. I am still confuzed with the syntax:
me (current object - but always the form?)
form
forms (when to use them)
..objectname
!objectname
[fieldname]

and how they're put together. I just copy samples, but don't know the rules.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top