?
Solved

Access VBA call subroutine that is in a subform

Posted on 2012-03-16
8
Medium Priority
?
716 Views
Last Modified: 2012-03-16
I created a subroutine that is located in a subform.
What's the syntax to call it from another [unrelated] form? I've tried everything I could think of.

Forms!MainForm!Subform.Form.GoToId (540)
0
Comment
Question by:etech0
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37729588
what is the sub routine ? post it here

make the sub Public instead of Private
0
 
LVL 10

Author Comment

by:etech0
ID: 37729605
Public Sub GoToId(ByVal RecID As Integer)
Dim rs As dao.Recordset

' set it to a clone of the form's recordset so that whatever you do doesn't affect the form just yet
Set rs = Me.RecordsetClone

rs.FindFirst "[id]=" & RecID

' if there's a match, set the form's bookmark to that of the rs' bookmark
If Not rs.NoMatch Then
    Me.Bookmark = rs.Bookmark
End If

Set rs = Nothing
End Sub
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37729630
what are the actual names of the
main form
subform
subform control
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 10

Author Comment

by:etech0
ID: 37729644
CatWebWork2F
CatWebWork2SummaryF

What control? The ID field is called ID.
0
 
LVL 10

Author Comment

by:etech0
ID: 37729647
The macro is in CatWebWork2SummaryF, and I'm trying to call it from another form entirely.
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1800 total points
ID: 37729664
try this

call Form_CatWebWork2SummaryF.GoToId (540)
0
 
LVL 9

Assisted Solution

by:macarrillo1
macarrillo1 earned 200 total points
ID: 37729673
I would remake this subroutine into a public subroutine in your code module. Then call as needed.

Public SubGoToId(ByVal RecID As Integer, fName as object)

' set it to a clone of the form's recordset so that whatever you do doesn't affect the form just yet
Set rs = fName.RecordsetClone

rs.FindFirst "[id]=" & RecID

' if there's a match, set the form's bookmark to that of the rs' bookmark
If Not rs.NoMatch Then
    fName.Bookmark = rs.Bookmark
End If

Set rs = Nothing
End Sub
0
 
LVL 10

Author Closing Comment

by:etech0
ID: 37729689
Whew - thanks!
macarrillo1: interesting idea, I'll keep it in mind.
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question