Subform OnCurrent "If"-Statement: Mainform New Record?

  • Thread starter Thread starter tbl
  • Start date Start date
T

tbl

How would I word some code in a subform's OnCurrent Event
such that if the main form is on a new record, then...

I've been trying "If Me.Parent.NewRecord = True then ...

but it doesn't seem to be working. It compiles ok, and
doesn't throw an error when it runs, but it doesn't appear
to be working when I open the forms.
 
what do you mean by "it doesn't *appear* to be working"? have you stepped
through the code to see what's actually happening at runtime?

hth
 
How would I word some code in a subform's OnCurrent Event
such that if the main form is on a new record, then...

I've been trying "If Me.Parent.NewRecord = True then ...

but it doesn't seem to be working. It compiles ok, and
doesn't throw an error when it runs, but it doesn't appear
to be working when I open the forms.

I suspect that the If statement will never under any condition be satisfied.
The instant you set focus to a subform, the main form record is written to
disk - and is therefore no longer the "new" (uncommitted, unwritten) record.

You'll need some other way to determine this.

John W. Vinson [MVP]
 
On Fri, 27 Jul 2007 04:12:48 GMT, "tina"


Thanks for the reply, Tina.

what do you mean by "it doesn't *appear* to be working"?


When the "If" condition is known to be true, the "then"
machinery doesn't go (how's that for technical?).

have you stepped
through the code to see what's actually happening at runtime?


No. I seem to have a bad mental block about code
manipulation. Probably stems from my broad base of
ignorance with respect to anything having to do with
programming. The debug window, watch expressions, etc. are
all things that I just can't seem to get my mind around.


I think John Vinson hit the nail on the head, tho.


The problem that I'm trying to squelch only happens when the
db is totally devoid of any data. If there's so much as one
record in the pertinent tables, everything works fine.

Like John said, I need to find a different approach.
 
I suspect that the If statement will never under any condition be satisfied.
The instant you set focus to a subform, the main form record is written to
disk - and is therefore no longer the "new" (uncommitted, unwritten) record.

You'll need some other way to determine this.


Thanks John.

I think you've nailed it. This error only happens on a
totally new, data-free db.
 
Back
Top