• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 765
  • Last Modified:

Code to avoid error - "Can't Go To Specified Record"

What VBA code in the property sheet for this form would help me by pass the error "Can't Got To Specified Record".

When the form is in "edit mode" and I try and advance to the next record, the aforementioned error is displayed.

If the form is in edit mode, and I attempt to move to the next record, I would like the form to save the record... and then advance to the next record.
Status of record prior to display of error message.Form-ProcModule.jpg
0
geekmee2
Asked:
geekmee2
  • 2
  • 2
1 Solution
 
geekmee2Author Commented:
Here is the property sheet for the "Next_Record" command button... so I know I am close:

Property sheet for Next_Record command button on form.
(I am not a programmer, but learning the basics of VBA for Access)
0
 
ltlbearand3Commented:
Without seeing more of your code it is hard to give specifics.  Hopefully I can help guide you some.  Ask questions as you need, as I am not sure how much programming you have done.

In general what you need to do is add in code at the beginning of the Next_Record event that calls the same code as is run by the save button on your form.  You will also need to find the code that is called when the Save button is clicked.  A simple fix is to just copy that code that saves the record and put that at the beginning of the code for the Next_Record event.  However, a better coding practice is to create a separate procedure that both the Save Button and the Button call.  That way the code is in one place and not two.  It is easier to maintain.

-Bear
0
 
geekmee2Author Commented:
I understand what you are saying overall, from my readings on procedures... but I guess there is only so much reading you can do... I guess it's time to start testing my assumptions...and start learning from my mistakes to get a clearer concept.

I have noticed that the behavior of the very last field "Followup"...If I tab out of that field it saves the record automatically.

In the Procedures window I see a subroutine for the Followup field:

 "Follow_Up_BeforeUpdate (Cancel As Integer)"

If I follow this convention it looks like I could create a subroutine for the Next_Record command button:

 "Next_Record_BeforeUpdate (Cancel As Integer)"

Am I on the right path?
0
 
ltlbearand3Commented:
Yes you are heading the in the right direction.  You might want to look at your code to see if there are any Next_Record procedures already defined and what they do.  If there are none (which may be the case in Access), then create the before update procedure.  Then look at the code in "Follow_Up_BeforeUpdate (Cancel As Integer)".  You will need to place some and maybe all that code in "Next_Record_BeforeUpdate (Cancel As Integer)"

-Bear
0
 
Jeffrey CoachmanMIS LiasonCommented:
The issue here is that you are opening your form to the "Last" record.

If you are on the last record, then that is literally the: "Last Record".
Hence it is impossible to go to the "Next Record".
This is why you are getting the error.

So if you are on the last record, then the "Next" record would actually have to be a *New* record.

So then we need to go back to the start....
Why are you opening the form on the last record?
A table in Access can be sorted in any way the user wants.
Hence the "Last" record, can be different each time.
If you really want to open the form to the *LAST ADDED* record, then you need to add a date stamp field to your table with a default value of: Now().
Then sort the recordsource of the form by this date field. (so the higheset date is first record)
Then all you have to do is Open the form.
Then this should all work normally.


JeffCoachman
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now