Solved

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

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

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
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…
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.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

688 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