Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2004, 08:31 AM
Authorized User
 
Join Date: Oct 2004
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default DoCmd.GoToRecord Error in Access VBA

When I give the code line DoCmd.GotoTorecord , ,acFirst, I get the error message :
Run-time error 2499: You cant use the GotoRecord action or method on an object in Design view.
I am pasting the whole vba code block here

DoCmd.GoToRecord , , acFirst
DoCmd.GoToRecord , , acNewRec


[Forms]![DietMain]![DietSubform].[Form]![Item] = rst![Item]
[Forms]![DietMain]![DietSubform].[Form]![SN] = rst![SN]
rst.MoveNext
DoCmd.GoToRecord , , acNext
Loop Until rst.EOF
rst.MoveNext
rst.Close 'close recordset.

End Sub


 
Old October 28th, 2004, 10:27 AM
Authorized User
 
Join Date: Oct 2004
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What is it you're trying to do with this code? Going to acFirst before doing acNewRec makes no sense. If you're trying to "put" records into a table by assigning values in the user interface, that's the wrong way to go about it. You should use an Append query or open a second recordset on the target table and write the values explicitly in code. Requery the form that is meant to display the records after you're done to show the new rows you just inserted.


John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"





Similar Threads
Thread Thread Starter Forum Replies Last Post
DoCmd.GoToRecord , , acNewRec doesnt create new re david_bridges Access VBA 1 August 21st, 2006 06:03 AM
DoCmd.GoToRecord Error in Access VBA myth12345 Access VBA 4 February 16th, 2006 01:58 AM
GoToRecord Error using VBA tied to Command Button pkaptein1 Access 5 May 28th, 2005 09:49 AM
DoCmd.GoToRecord Error in Access VBA myth12345 Access VBA 1 October 30th, 2004 07:29 AM
DoCmd.GoToRecord Error myth12345 VB How-To 0 October 28th, 2004 07:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.