record vanishes on acNewRec

R

redFred

OK...it doesn't really because it is in the table. But it does vanish from
my form, until requeried.

I have a subform on my main form; it has a subform which has a subform which
contains the form I am adding a record to. During an event on a main form
command button I create a record in the targeted subform. Everything appears
fine except the data displayed on the main form disappears. I have debugged
this to the code "DoCmd.GoToRecord , , acNewRec". That's what makes the data
vanish from display.

Inserting a main form requery would probably work, but takes a lot of time
to accomplish.

I think it is a focus issue, but cannot get it right. If I am on [formMain]
and want to add a record to
[formMain].[formSubform1].[formSubform2].[formSubform3] What is the correct
code for the command button on the main form? BTW, subform2 and subform3 are
on a tab control of subform1. I don't think that matters, however.

The code that fails is:
Forms![formMain]!Reservationfrm.Form.tabJob.SetFocus
Forms![frm1 Client]!Reservationfrm!Jobfrm!Invoicefrm.SetFocus
DoCmd.GoToRecord , , acNewRec

I thought I had this and understood, but I ask help again.

Thanks.
 
D

Dale Fye

Fred,

Have you tried something like:

docmd.GoToRecord acDataForm, "formname", acNewRec

Where you replace "formname" with the path (Forms![frm1 Client]!......) to
your subform3, instead of trying to set the focus to the control or the form?

Dale
 
R

redFred

Thanks for responding, Dale.

I tried this code: DoCmd.GoToRecord
acDataForm, _ "Forms![frm1 Client]!Reservationfrm!Jobfrm!Invoicefrm", acNewRec

It threw a runtime error 2489, form not open.

I tried it with and without setting focus to Invoicefrm -- same result.

See anything else?

Dale Fye said:
Fred,

Have you tried something like:

docmd.GoToRecord acDataForm, "formname", acNewRec

Where you replace "formname" with the path (Forms![frm1 Client]!......) to
your subform3, instead of trying to set the focus to the control or the form?

Dale
--
Don''t forget to rate the post if it was helpful!

Email address is not valid.
Please reply to newsgroup only.


redFred said:
OK...it doesn't really because it is in the table. But it does vanish from
my form, until requeried.

I have a subform on my main form; it has a subform which has a subform which
contains the form I am adding a record to. During an event on a main form
command button I create a record in the targeted subform. Everything appears
fine except the data displayed on the main form disappears. I have debugged
this to the code "DoCmd.GoToRecord , , acNewRec". That's what makes the data
vanish from display.

Inserting a main form requery would probably work, but takes a lot of time
to accomplish.

I think it is a focus issue, but cannot get it right. If I am on [formMain]
and want to add a record to
[formMain].[formSubform1].[formSubform2].[formSubform3] What is the correct
code for the command button on the main form? BTW, subform2 and subform3 are
on a tab control of subform1. I don't think that matters, however.

The code that fails is:
Forms![formMain]!Reservationfrm.Form.tabJob.SetFocus
Forms![frm1 Client]!Reservationfrm!Jobfrm!Invoicefrm.SetFocus
DoCmd.GoToRecord , , acNewRec

I thought I had this and understood, but I ask help again.

Thanks.
 
J

John W. Vinson

Thanks for responding, Dale.

I tried this code: DoCmd.GoToRecord
acDataForm, _ "Forms![frm1 Client]!Reservationfrm!Jobfrm!Invoicefrm", acNewRec

It threw a runtime error 2489, form not open.

I tried it with and without setting focus to Invoicefrm -- same result.

The underscore is misplaced here, which might be due to word wrap in the
newsgroup post. A blank followed by an underscore at the END of a line
indicates that the statement continues on the next line.

I suspect, though, that the problem is your syntax. Check that each step in
the chain of subforms is showing the name *of the Subform control*, the
container on the form in which a subform is displayed - this might or might
not be the same as the name of the Form object within that container. It may
also be helpful to explicitly use the Form property of each subform control:

Forms![frm1 Client]!Reservationfrm.Form!Jobfrm.Form!Invoicefrm


John W. Vinson [MVP]
 
R

redFred

Thanks, John.

Yes, the underscore was at the line break in my original message, not in my
used code.

All the subform control names are correct.

I tried the form property on each:
DoCmd.GoToRecord acDataForm, "Forms![frm1
Client]!Reservationfrm.Form!Jobfrm.Form!Invoicefrm", acNewRec

I get the error code 2489, the object:
Forms![frm1 Client]!Reservationfrm.Form!Jobfrm.Form!Invoicefrm
is not open.

I'm lost.


John W. Vinson said:
Thanks for responding, Dale.

I tried this code: DoCmd.GoToRecord
acDataForm, _ "Forms![frm1 Client]!Reservationfrm!Jobfrm!Invoicefrm", acNewRec

It threw a runtime error 2489, form not open.

I tried it with and without setting focus to Invoicefrm -- same result.

The underscore is misplaced here, which might be due to word wrap in the
newsgroup post. A blank followed by an underscore at the END of a line
indicates that the statement continues on the next line.

I suspect, though, that the problem is your syntax. Check that each step in
the chain of subforms is showing the name *of the Subform control*, the
container on the form in which a subform is displayed - this might or might
not be the same as the name of the Form object within that container. It may
also be helpful to explicitly use the Form property of each subform control:

Forms![frm1 Client]!Reservationfrm.Form!Jobfrm.Form!Invoicefrm


John W. Vinson [MVP]
 

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