Moving to a subform within the main form

K

Kathy Ratermann

I created a form that conatins two subforms. I am trying
to put two Command Buttons on the main form; one to move
to the first new record in Subform 1 and the other to move
to the first new record in Subform 2. I tried building a
macro to accomplish this, but I get a message telling me
the I am referring to an object that is not open. If I
change the macro to open the subform and then go to new
record, it opens the subform by itself, rather than just
moving me to the subform embedded in the main form. So
basically, I am having difficulty telling the program to
move from the main form to a subform. Anyone have an
answer for me?
 
I

Ian

-----Original Message-----
I created a form that conatins two subforms. I am trying
to put two Command Buttons on the main form; one to move
to the first new record in Subform 1 and the other to move
to the first new record in Subform 2. I tried building a
macro to accomplish this, but I get a message telling me
the I am referring to an object that is not open. If I
change the macro to open the subform and then go to new
record, it opens the subform by itself, rather than just
moving me to the subform embedded in the main form. So
basically, I am having difficulty telling the program to
move from the main form to a subform. Anyone have an
answer for me?
.

Reply,

See code below. In this example Sub1 is 1st subform &
sub2 is second subform.

What you have to do is first move to subform then goto
first record.

This is for first command button


DoCmd.GoToControl "sub1"
DoCmd.GoToRecord , , acFirst

This is for second command button

DoCmd.GoToControl "sub2"
DoCmd.GoToRecord , , acFirst


Hope this helps

Ian
 
K

Kathy Ratermann

Ian,

Thank You, Thank You, Thank You! You have no idea how
much time I have spent fooling around with this problem.
I wasn't treating the subform like a control, that was the
key. I tried what you said and it worked perfectly!
Thanks again. I can finally move on!!

Kathy
 

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