Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to trigger the next record button on an access form via vba?

Posted on 2016-10-13
10
Medium Priority
?
57 Views
Last Modified: 2016-10-21
I’m trying to call the below macro from another module and it does work, but it’s a hit or miss.  Is there a better way to do it?

Public Sub btnNextRecord_Click()
    DoEvents
    DoCmd.GoToRecord , , acNext
End Sub

Open in new window


Just in case it matters, here is how I’m calling it.
Call Forms("frmMyTicketAudits").btnNextRecord_Click

Open in new window

0
Comment
Question by:kbay808
[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
  • 5
  • 5
10 Comments
 
LVL 39

Expert Comment

by:PatHartman
ID: 41842307
If you want to make common code, put it into a standard module.  Forms are classes and they are not available unless the form is open.
0
 

Author Comment

by:kbay808
ID: 41842369
I will always have the form open and I'm calling it from a standard module.
0
 
LVL 39

Expert Comment

by:PatHartman
ID: 41842382
It only makes sense to call it from a form.  in a standard module, you don't have a bound recordset which is what this code affects.
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 

Author Comment

by:kbay808
ID: 41842392
The reason why I'm calling it from a standard module is because I am calling it from Excel.
0
 
LVL 39

Expert Comment

by:PatHartman
ID: 41842418
Can you tell us what you are trying to do with this code and why you are running it in Excel.  If you are attempting to process a recordset, this is the wrong approach.  You would simply open a recordset using ADO and process that in EXCEL without automating Access.
0
 

Author Comment

by:kbay808
ID: 41843640
I have an excel file that compiles and processes that data.  I have code that updates all of the fields in an access form from excel that works great.  The only thing that I can’t do consistently is click the next record.  My goal is to be able have the user not have to go back and forth between excel and access.  The access form will always be open during this process.
0
 
LVL 39

Accepted Solution

by:
PatHartman earned 2000 total points
ID: 41843673
Let's start with - form's don't store data.  Tables store data.  That means that your Excel app, if you are using it to update data (and I'm having trouble with that also but that's a different issue), should be updating a table NOT trying to poke data into an open form.  

If you want to use Excel to update data in an Access table, do it by opening a recordset in Excel and updating that way or by running an update query.  Do not do this by manipulating forms.   If you are doing this because you have code in the form's BeforeUpdate event that needs to run, why not just do the data entry in Access and eliminate Excel from the process?  You can export the data back to Excel when you are done.
0
 

Author Comment

by:kbay808
ID: 41843694
You way make more sense.  I will work on doing it that way.
0
 

Author Closing Comment

by:kbay808
ID: 41853997
Thanks for your help
0
 
LVL 39

Expert Comment

by:PatHartman
ID: 41854038
Glad to help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

715 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