Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Proper call & parameters to "docmd.gotorecord" from a form where target code is in a module

Posted on 2013-10-26
4
Medium Priority
?
662 Views
Last Modified: 2013-10-26
Hi

I am using Office 356 ----  Microsoft Access

I would like to put the following code in a module

Public Sub DoThis(????  )
     DoCmd.GoToRecord , , acFirst
End Sub

Open in new window


I would appreciate an example of a call to this sub as well as correcting that code above

Thanks
0
Comment
Question by:peispud
[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
  • 2
  • 2
4 Comments
 
LVL 75
ID: 39603266
The code you have would most likely go behind a Command Button, to go to the first record on a Form.


Private Sub btnFirst_Click()
    'Goto the frist record on the Form
    DoCmd.GoToRecord , , acFirst
   
End Sub
0
 

Author Comment

by:peispud
ID: 39603292
I have no problem running the code when the code is in it's normal place (Form VBA)

I would like to run that code  in a module ,  so that code in other forms can use the same routine.


So, that's not the answer that I am looking for.
0
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 2000 total points
ID: 39603300
Sorry .... OK ... put this code in a standard Module

Public Sub GoToFirstRecord()
     DoCmd.GoToRecord acDataForm, Screen.ActiveForm.Name, acFirst
End Sub

Then ... from where ever, you can call like this:

Call GoToFirstRecord
0
 

Author Closing Comment

by:peispud
ID: 39603303
That's perfect!

Thank you.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

609 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