Solved

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

Posted on 2013-10-26
4
598 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

803 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