473,657 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DoCmd.GoToRecor d , , acNewRec

5 New Member
I have been using this forum to answer many questions regarding an Access database I am building (my first attempt at something like this - teaching myself as I go), and I've always been able to find solutions. My problem now has been addressed in other posts, but none of the solutions given are working for me.

The database will be used for tracking changes that I make to a customer's pricing, with forms based on queries that will allow me to review these changes at a determined interval, decide if the change is paying off, and then either Leave it, Change it Back, Modify It, or Give it More Time (review it again in the future).

The issue I am having now just popped up - it was working as of 2 days ago, but something changed and now it's not.

I have a form that calls a query, ReviewSearchRec ords, that shows records that are due to be reviewed this week, based on information put into the original record. On this form, the user inputs DateReviewed, ResultsSinceCha nge(memo), ActionToTake(4 choices based on a combo box), and ActionNotes(mem o). Depending on which ActionToTake is chosen, different things will occur, messages pop up, etc.

The problem is with ActionToTake="G ive It More Time". I have set it up so that when this selected and the record is saved, a new record will be inserted into the table with much of the same data as the original, with some data altered per user input via an InputBox, etc.

As I mentioned, this was working fine until recently. Now, I am receiving a RunTime 2105 You Can't Go To Specified Record, and the debugger takes me to the DoCmd.GoToRecor d , , acNewRec line.

To rule things out based on what I've read in other posts - the form is set to allow additions. I had most of the fields that were displayed set to Locked=Yes on the form because I didn't want these to be changed via this form. To be sure, I set all these to No, but still received same error.


I am running Access 2000. Any help would be appreciated. I am posting my entire BeforeUpdate code, even though some of it may not be needed.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If MsgBox("Save Changes?", vbYesNo + vbQuestion) = vbNo Then
  3. Cancel = True
  4. MsgBox ("Changes not saved.  Click Undo Changes to return record to original settings, or save the record")
  5. GoTo exitForm_BeforeUpdate
  6. Else
  7. If ActionToTake = "Give It More Time" Then
  8.  
  9. Dim promptWeeks As String
  10. promptWeeks = InputBox("Enter number of additional weeks until next review", , "8")
  11.  
  12. If promptWeeks = "" Then
  13.  
  14. MsgBox ("If you want to have this record come up for review again in the future, you must enter the number of weeks until the next review")
  15. GoTo exitForm_BeforeUpdate
  16. End If
  17.  
  18. sStoreGroup = StoreGroup
  19. sDate = DateReviewed
  20. sWeeksToReview = WeeksToReview
  21. sAccount = Account
  22. sGLID = GLID
  23. sRequestFrom = RequestFrom
  24. sAccountToCopy = AccountToCopy
  25. sOldDG = OldDG
  26. sNewDG = NewDG
  27. sLine1 = Line1
  28. sUD1 = UD1
  29. sLine2 = Line2
  30. sUD2 = UD2
  31. sLine3 = Line3
  32. sUD3 = UD3
  33. sLine4 = Line4
  34. sUD4 = UD4
  35. sLine5 = Line5
  36. sUD5 = UD5
  37. sNotes = Notes
  38.  
  39.  
  40. DoCmd.GoToRecord , , acNewRec
  41.  
  42. StoreGroup = sStoreGroup
  43. Date = sDate
  44. WeeksToReview = promptWeeks
  45. Account = sAccount
  46. GLID = sGLID
  47. RequestFrom = sRequestFrom
  48. AccountToCopy = sAccountToCopy
  49. OldDG = sOldDG
  50. NewDG = sNewDG
  51. Line1 = sLine1
  52. UD1 = sUD1
  53. Line2 = sLine2
  54. UD2 = sUD2
  55. Line3 = sLine3
  56. UD3 = sUD3
  57. Line4 = sLine4
  58. UD4 = sUD4
  59. Line5 = sLine5
  60. UD5 = sUD5
  61. Notes = "**Holdover from " & Date & " Review** " & sNotes
  62.  
  63. MsgBox "A New Record Has Been Added with a Date of " & Date & " so the the pricing can be reviewed in the future."
  64. End If
  65.  
  66.  
  67. If ActionToTake = "Change It Back" Then
  68. MsgBox "Record updated, but not finalized.  Please use the Action Required form from the Switchboard after feedback from the field to finalize this record."
  69. End If
  70. If ActionToTake = "Modify It" Then
  71. MsgBox "Record updated, but not finalized.  Please use the Action Required form from the Switchboard after feedback from the field to finalize this record."
  72. End If
  73. If ActionToTake = "Leave It As Is" Then
  74. MsgBox "Record Updated and finalized."
  75. End If
  76. End If
  77.  
  78. exitForm_BeforeUpdate:
  79. Exit Sub
  80.  
  81. End Sub
  82.  
Feb 1 '08 #1
2 3435
Denburt
1,356 Recognized Expert Top Contributor
And you said this has been working? Try placing this code in the after update event.

http://kbalertz.com/128195/Commands-...ate-Event.aspx
Feb 1 '08 #2
aaronyoung
5 New Member
Hi - Thanks for the quick reply.

Yes, it was working at one point, but after reading the link you posted, I guess I'm not sure how.

At one point, I believe I had this loaded into an OnClick event, but decided on the BeforeUpdate so that if the form was dirty, it would force the user to either save or undo before moving to the next record (using the navigation buttons) and just confirming the desire to save the changes if the button was clicked. I am almost positive that I switched this to a BeforeUpdate event some time ago, and that I have had it working (i.e. adding the new record properly) since I did this, but perhaps I am losing my mind (an entirely likely possibility).

To follow up, moving this to the AfterUpdate event made the Add Record part work, however it made the first part of my code useless, i.e. the confirmation that you want to save. To fix this, I split the code up and now have, as a BeforeUpdate event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2.  
  3.  
  4. If MsgBox("Save Changes?", vbYesNo + vbQuestion) = vbNo Then
  5. Cancel = True
  6. MsgBox ("Changes not saved.  Click Undo Changes to return record to original settings, or save the record")
  7. GoTo exitForm_BeforeUpdate
  8.  
  9. End If
  10.  
  11. exitForm_BeforeUpdate:
  12. Exit Sub
  13.  
  14.  
  15. End Sub
  16.  
And my AfterUpdate event is:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_AfterUpdate()
  2.  
  3. If ActionToTake = "Give It More Time" Then
  4.  
  5. Dim promptWeeks As String
  6. promptWeeks = InputBox("Enter number of additional weeks until next review", , "8")
  7.  
  8. If promptWeeks = "" Then
  9.  
  10. MsgBox ("If you want to have this record come up for review again in the future, you must enter the number of weeks until the next review")
  11. GoTo exitForm_AfterUpdate
  12. End If
  13.  
  14. sStoreGroup = StoreGroup
  15. sDate = DateReviewed
  16. sWeeksToReview = WeeksToReview
  17. sAccount = Account
  18. sGLID = GLID
  19. sRequestFrom = RequestFrom
  20. sAccountToCopy = AccountToCopy
  21. sOldDG = OldDG
  22. sNewDG = NewDG
  23. sLine1 = Line1
  24. sUD1 = UD1
  25. sLine2 = Line2
  26. sUD2 = UD2
  27. sLine3 = Line3
  28. sUD3 = UD3
  29. sLine4 = Line4
  30. sUD4 = UD4
  31. sLine5 = Line5
  32. sUD5 = UD5
  33. sNotes = Notes
  34.  
  35. DoCmd.GoToRecord , , acNewRec
  36.  
  37.  
  38. StoreGroup = sStoreGroup
  39. Date = sDate
  40. WeeksToReview = promptWeeks
  41. Account = sAccount
  42. GLID = sGLID
  43. RequestFrom = sRequestFrom
  44. AccountToCopy = sAccountToCopy
  45. OldDG = sOldDG
  46. NewDG = sNewDG
  47. Line1 = sLine1
  48. UD1 = sUD1
  49. Line2 = sLine2
  50. UD2 = sUD2
  51. Line3 = sLine3
  52. UD3 = sUD3
  53. Line4 = sLine4
  54. UD4 = sUD4
  55. Line5 = sLine5
  56. UD5 = sUD5
  57. Notes = "**Holdover from " & Date & " Review** " & sNotes
  58.  
  59. MsgBox "A New Record Has Been Added with a Date of " & Date & " so the the pricing can be reviewed in the future."
  60.  
  61. End If
  62.  
  63. If ActionToTake = "Change It Back" Then
  64. MsgBox "Record updated, but not finalized.  Please use the Action Required form from the Switchboard after feedback from the field to finalize this record."
  65. End If
  66. If ActionToTake = "Modify It" Then
  67. MsgBox "Record updated, but not finalized.  Please use the Action Required form from the Switchboard after feedback from the field to finalize this record."
  68. End If
  69. If ActionToTake = "Leave It As Is" Then
  70. MsgBox "Record Updated and finalized."
  71. End If
  72.  
  73. exitForm_AfterUpdate:
  74. Exit Sub
  75.  
  76. End Sub
  77.  
This creates another problem, because once the new record is entered, I can't save the new record because of a 2115 runtime error, which, from the quick searching I have done on it, is because I am trying to save the new record when the BeforeUpdate event has already been triggered (due to saving the original record). I'll try to devise a solution to this and if I can't come up with anything will post a fresh question. This question, regarding the 2105 error, has been answered - thanks for your help.
Feb 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
12564
by: Eric | last post by:
What's the best way to cancel the new record when doCmd.GoToRecord , , acNewRec is executed and before the new record is actually written to the database. I'm maintaining an existing Access 97 application. The main order form's recordsource is a query. On the form is an add button that uses doCmd.GoToRecord , , acNewRec to display an empty record and place the user in the first field. If the user tabs out of the first field (assuming...
0
1757
by: Timppa | last post by:
Hi, I'm converting ACCESS 2000 database to SQL Server. I have .adp project. In the .mdb I have form where I'll insert rows into two different tables using docmd.GoToRecod ,,acNewRec. In .adp form's Record source property I have following Stored Procedure (in .mdb there were similar query).
6
68676
by: David | last post by:
I am trying to insert an employee number into the EmpNbr field in my main table from a form where I add a new employee to my employee table. I was hoping this command would work, but it isn't. DoCmd.RunSQL "INSERT INTO VALUES ()", 0 This is the only field I want to populate in the main table from this form. there are three other fields in the main table that I want to leave unpopulated.
5
15797
by: Stack | last post by:
Hello, I have my data sorted on date desc in my form (multiple recs/table style). When I want to insert a new record (with my self made button and vba code(DoCmd.GoToRecord , , acNewRec)) the prompt will go after the last record of my form. Is there a way to insert BEFORE the first record (so before the last inserted record) in top of my screen? It would surprise me though! Stack
3
17337
by: sajid_yusuf | last post by:
Hi My MS-Access 2003 "Form" is bind to a SQL server 2000 table but I wonder why doesn't it accept the following command and displays an error that "You can't go to the specified record". It works well with MS Access tables but creates problem when the backend table belongs to SQL server : DoCmd.GoToRecord , , acNewRec
8
1963
JAMBAI
by: JAMBAI | last post by:
Hi, Is there a way to handle single quotes when inserting the records using the below do command. Or do I need to write Insert sql. DoCmd.GoToRecord , , acNewRec Thanks Jambai
1
2593
by: vostrixos | last post by:
Hi all,i need some help I'm working on a access project were i use a lot the docmd.gotorecord ,,next ..first ..last method and i use only once the DoCmd.GoToRecord , , acNewRec.Everything was fine until i had to change the pop up property in a form.When that property is set to "yes" i get the error message: "you can't use the goto record action or method on an object in design view" I don't get that.wich object is on design vew.Is it the...
3
4883
martintallett
by: martintallett | last post by:
Help! I am trying to replace the Access Find button functionality on an old database. I can make it work when I use a basic form with bound fields and a button which shows a popup form which then finds the record the user wants then does a GoToRecord on the basic form. However... When I try to put this to work in the real world the form with the record context to GoToRecord is a subform and it only partially works.
5
11127
by: phill86 | last post by:
Hi I have a main form that holds records for scheduled meetings, date time location etc... in that form i have a sub form that has a list of equipment resources that you can assign to the meeting in the main form. I have two buttons in the sub form one for selecting and copying all the records and another for pasting the records this enables me to copy and paste the equipment resources from one scheduled meeting to another. The buttons are...
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.