Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

I wish to allow my user to go back and verify the work just completed. Using "DoCmd.GoToRecord , "InvDistribution", acLast" to get to the last row stored in the table, I get an error message that the "Object "InvDistribution" isn't open." Why is the table not open? I am still in the same bound form, I think.

Could someone please tell me what is the proper sequence of commands to get the last row added to the table and then the previous row and then the next previous row, etc?

TIA
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
Wendell
4StarLounger
Posts: 482
Joined: 24 Jan 2010, 15:02
Location: Colorado, USA

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by Wendell »

I believe the issue is that you haven't specified what type of object you are dealing with - if InvDistribution is a form, it should read:
DoCmd.GoToRecord(acDataForm, "InvDistribution",acLast)
Wendell
You can't see the view if you don't climb the mountain!

User avatar
HansV
Administrator
Posts: 78540
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by HansV »

Do you run this code from the form InvDistribution? If so, you can also use

RunCommand acCmdRecordsGoToLast
Best wishes,
Hans

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

Gentlemen:

Thanks for trying.

As usual, not knowing very much :groan:, I did not specify all the pertinent information.Let me try again:

form name : frm5-2-3 InvDistribution (This is subform of frm5-2-0 Inventory Maintenance)
table name: InvDistribution

The desire is to be able to retrieve into the bound form frm5-2-3 InvDistribution the last row stored by that form and then sequentially previous rows with the ability to update any row that is presented.

Thanks,
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
HansV
Administrator
Posts: 78540
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by HansV »

From which form do you want to run the code? From the main form 'frm5-2-0 Inventory Maintenance' or from the subform 'frm5-2-3 InvDistribution'?
Best wishes,
Hans

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

From the subform frm5-2-3 InvDistribution.
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
HansV
Administrator
Posts: 78540
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by HansV »

In that case, the line

RunCommand acCmdRecordsGoToLast

should do what you want.
Best wishes,
Hans

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

Hans

Thank you.

I can get to the last row that has been stored as long as I stay in the form. If I get out of the form I cannot retrieve the last row with this command.

I also find that I cannot go to the previous record with acCmdRecordsGoToPrevious. I get the "Command or Action is not available now" error message if the previous row was not stored in the "current session".

I apparently do not understand the workings of acCmdRecordsGoTo . . .

I will have to try someting else.
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
HansV
Administrator
Posts: 78540
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by HansV »

You stated earlier that you wanted to run the code from the subform. Now you mention "If I get out of the form I cannot retrieve the last row with this command", so I don't really understand what you're trying to do.

Perhaps you could try to explain more clearly and precisely what you want to accomplish...
Best wishes,
Hans

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

Hans,

I am really sorry that I am not as precise as required. Let me start with the basics.

I have a VERY non-technical user. He makes every conceivable data entry error possible. I, not being as proficient as I once was, have not caught all possible errors that could conceivably be made and then those which he makes that are totally inconceivable.

The main form (5-2-0) in question has 3 bound subforms, 5-2-1, 5-2-2 and 5-2-3. When the user is entering data, he makes mistakes which may not be evident at the immediate time of the mistake. When he finishes adding all the data he then takes a look at the totals which have been accumulated in the main form 5-2-0. He may then see that a certain accumulator is askew and want to go back and check the data entered into any or many of the three subforms. I had hoped that because the tables for each of the three subforms is bound that I could just get the last row in the bound table and then let him back up until he (hopefully) found his error, correct the data in the bound table and then update the row in the table.

If there is not a way to accomplish this task my way, then I will have to make a continuous form for each of the three tables and let him go in that way, but that will not let him have all the data together.
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
HansV
Administrator
Posts: 78540
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by HansV »

How do you want to let the user go to the last record? By clicking a button on the main form, or ...?
Best wishes,
Hans

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

Hans,

Each of the three subforms have buttons for last record and for previous record. Needless to say, they are not working at this time. They are intended to work with the table represented by the subform.
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
HansV
Administrator
Posts: 78540
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by HansV »

Try creating the buttons using the control wizard: make sure the "Use Control Wizards" button in the Design tab of the ribbon is "on":
x122.png
If you then place a command button on the subform (in design view), the Control Wizard will start. The Record Navigation category includes a command for going to the last record:
x123.png
The wizard will create the correct On Click code for the button.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

Hi Hans,

Thank you so very much AGAIN. I thought I had tried using the wizard and having it not work, but at least the first of the three subforms works perfectly. Last or First and then Previous or Next.

You da man!
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

Hans,

I may have spoken too quickly. The first sub form worked, but the second subform did not work. The code generated looks the same to me but it does nothing. The last subform does not work either
Last edited by PaulW on 08 May 2010, 00:12, edited 1 time in total.
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
HansV
Administrator
Posts: 78540
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by HansV »

I'm afraid I'll have to know much more about the subform, and preferably see a stripped down, compacted and zipped copy of the database.
Best wishes,
Hans

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

It will take a bit of time but I will send it to you. Thanks
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
HansV
Administrator
Posts: 78540
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by HansV »

It's bedtime for me anyway, so no hurry.
Best wishes,
Hans

PaulW
2StarLounger
Posts: 125
Joined: 17 Feb 2010, 16:25

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by PaulW »

Hi Hans,

I was putting together an MDB for you. My wife, the access maven of the family, came in and asked me what was wrong. We discovered that the "Data Entry" option on the two of the three forms was set to "yes". We changed the option on the two subforms that did not work to "data entry=no" and everything seems to be working now.

We are both wondering what this option means and why it is so UNintuitive. One would think that it would "allow data entry", but apparently not.

So sorry to have wasted your time.
PaulW
Lost Wages, NV USA
(former Cobol Programmer)

User avatar
HansV
Administrator
Posts: 78540
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Access 2007 "DoCmd.GoToRecord , "InvDistribution", acLast"

Post by HansV »

The naming of that option is indeed counterintuitive. The term comes from the job of data entry clerk; such a person receives filled-in paper forms and enters them into the computer.

If you set Data Entry to No (the default value), you can edit existing records and create new ones.
If you set Data Entry to Yes, you can only create new records; existing records will not be visible.
Best wishes,
Hans