Solved

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

Posted on 2016-10-13
10
29 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
  • 5
  • 5
10 Comments
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
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
Comment Utility
I will always have the form open and I'm calling it from a standard module.
0
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
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
 

Author Comment

by:kbay808
Comment Utility
The reason why I'm calling it from a standard module is because I am calling it from Excel.
0
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:kbay808
Comment Utility
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 34

Accepted Solution

by:
PatHartman earned 500 total points
Comment Utility
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
Comment Utility
You way make more sense.  I will work on doing it that way.
0
 

Author Closing Comment

by:kbay808
Comment Utility
Thanks for your help
0
 
LVL 34

Expert Comment

by:PatHartman
Comment Utility
Glad to help.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

11 Experts available now in Live!

Get 1:1 Help Now