INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Run a control on one subform from a button on another subform.

Run a control on one subform from a button on another subform.

Run a control on one subform from a button on another subform.

(OP)
Hi. I need to run a control on one subform from a button on another subform. Alternatively, I need to scroll through records on one subform by using a button on another subform. What VBA syntax should I use?

RE: Run a control on one subform from a button on another subform.

to refer to another subform from the current subform on the same mainform
Me.parent.OtherSubformControlName.Form
where "OtherSubformControlName" is the name of the other subform control and not necessarily the same name as the name of the form inside the subform control
the .Form then returns the form object within that control

RE: Run a control on one subform from a button on another subform.

There are several ways to scroll the records
You can use the docmd.gotorecord
or you can manipulate the recordset. In either case you should check if you try to go beyond the first or last record.

CODE -->

'To move next
Dim frm as access.form
Dim rs as dao.recordset
set frm = me.parent.othersubformcontrolname.form
set rs = frm.recordset
if rs.absoluteposition = rs.recordcount - 1 then 
  msgbox "last record"
else
  rs.movenext
end if 

RE: Run a control on one subform from a button on another subform.

(OP)
That second piece did the trick. Thank you!

RE: Run a control on one subform from a button on another subform.

The nice think to do to show your appreciation is to click on Greet Post link in the helpful post.

Have fun.

---- Andy

There is a great need for a sarcasm font.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close