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
Solved

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

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 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