Solved

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

Posted on 2013-10-26
4
565 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
  • 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 - Access MVP) earned 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now