Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 06-01-2010, 01:06 PM   #1
Alexie
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Alexie is on a distinguished road
Runtime error 2046 on doCmd.gotoRecord after doCmd.openReport

In a form, I have a button with the following sub onClick:
Private Sub btn_both_Click()
DoCmd.OpenReport "R_products", acViewPreview
DoCmd.GoToRecord acDataForm, "F_products", acNewRec
End Sub

But when I click on the button, that 2046 error occurs, "The command or action 'GotoRecord" isn't available now"

Interestingly, if I run that two DoCmd in 2 buttons separately in the form with the following code, they all works fine.
Private Sub btn_New_Click()
DoCmd.GoToRecord acDataForm, "F_products", acNewRec
End Sub

Private Sub btnRpt_Click()
DoCmd.OpenReport "R_products", acViewPreview
End Sub
it seems that that two DoCmd can't be running in a same precedure or I missed something?

Please help! Thanks a lot!


Last edited by Alexie; 06-01-2010 at 01:16 PM.
Alexie is offline   Reply With Quote
Old 06-02-2010, 02:47 AM   #2
KenHigg
Registered User
 
Join Date: Jun 2004
Posts: 13,309
Thanks: 8
Thanked 184 Times in 158 Posts
KenHigg has a spectacular aura about KenHigg has a spectacular aura about
Re: Runtime error 2046 on doCmd.gotoRecord after doCmd.openReport

Seems you should close the report before opening the form?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

ken

“You don’t learn to walk by following rules. You learn by doing, and by falling over.”
KenHigg is offline   Reply With Quote
Old 06-02-2010, 08:30 PM   #3
Alexie
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Alexie is on a distinguished road
Re: Runtime error 2046 on doCmd.gotoRecord after doCmd.openReport

Ken, The form (where the "do both" button is ) is opened. You meant close the report before gotoRecord?

What I really want to do is, by clicking one button, to print a report and then go to NewRec for new entry.

I tried to use Macro, but same error.

Such error is very easy to reproduce. Wonder if any one had the same problem on their system?

Alexie is offline   Reply With Quote
Old 06-03-2010, 02:58 AM   #4
KenHigg
Registered User
 
Join Date: Jun 2004
Posts: 13,309
Thanks: 8
Thanked 184 Times in 158 Posts
KenHigg has a spectacular aura about KenHigg has a spectacular aura about
Re: Runtime error 2046 on doCmd.gotoRecord after doCmd.openReport

Hum... Since you have the report in preview the maybe do the goto new record in a report event like when it closes or prints?

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

ken

“You don’t learn to walk by following rules. You learn by doing, and by falling over.”
KenHigg is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Gurus: Conditional Printing dyaron Modules & VBA 1 01-12-2008 10:03 AM
How do I suppress "Print Macro Definition" rkw12345 Macros 6 11-08-2006 04:33 PM
[SOLVED] Help with not null & DoCmd.OpenReport lindsRed Modules & VBA 1 07-13-2006 02:50 AM
[SOLVED] Help with not null & DoCmd.OpenReport lindsRed Modules & VBA 2 07-12-2006 11:53 PM
NoData Report - skip printing and go to next report Mike Hughes Reports 5 03-20-2003 03:42 PM




All times are GMT -8. The time now is 02:09 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World