[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Access VBA call subroutine that is in a subform

Posted on 2012-03-16
8
Medium Priority
?
719 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

656 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