473,325 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Move to Last record on a subform

I have built a database with a <Mainform> and a <Subform>. My problem is
twofold.

1. My subform is set as a continuos form with AllowAddiotions set to NO (ie.
a list of Issues to the client on the mainform)
2. To add new issues, a button is used and a pop-up form is used to add an
issue with more detail than what's available on the subform.
3. On accepting the new Issue from the pop-up the pop-up closes and you are
returned to the subform, and the new line is added, but the active record is
the first record and not the new one.

Problem: I have tried docmd.runcommand accmdrecordsgotolast and
docmd.GoToRecord acDataForm ,,acLast with no avail. I am getting errors
that the cmd is not available. I preface that with a requery and moving
control to the subform, either to the form itself or field on the subform,
still no luck. If I use the GoToRecord and specify the
Foms!mainform!subform as the object, I get an error that tells me the form
is not open (but it is).

Is there an easy way to move to the last record, I'm not certain what I may
be doing wrong.

The second problem I am running into is I need an event to occur when I move
out of a record (similar to onExit) and not into record that OnCurrent
provides. The afterupdate is of no use to me since changes may not occur.

Any help would be appreciated.

Thanks
Nov 12 '05 #1
1 22906
This code will requery the record in the subform, and move focus to the last
record:

Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form
  2. Set frm = Forms![YourMainForm]![YourSubformControl].Form
  3. frm.Requery
  4. With frm.RecordsetClone
  5. If .RecordCount > 0 Then
  6. .MoveLast
  7. frm.Bookmark = .Bookmark
  8. End If
  9. End With
  10. Set frm = Nothing
There is no event of exiting a record. The solution might depend on what you
need to do, but one approach is to declare a form-level variable to store
the primary key value, and then read it in the form's Current or Unload
event (the 2 occasions when you "leave" a record).

In the General Declarations of the form's module (at the top, with the
Option statements):
Dim mvarID As Variant

In the Current event procedure of the form:
Expand|Select|Wrap|Line Numbers
  1. Dim strMsg As String
  2. If Not IsEmpty(varID) Then
  3. If IsNull(varID) Then
  4. strMsg = "You just left the new record"
  5. Else
  6. strMsg = "You just left record ID " & mvarID
  7. End If
  8. mvarID = Me.[YourPrimaryKeyField]
  9. MsgBox strMsg
  10. End If
Do something similar in the form's Unload event.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"sixsoccer" <si*******@yahoo.com> wrote in message
news:Vu******************@news04.bloor.is.net.cabl e.rogers.com...
I have built a database with a <Mainform> and a <Subform>. My problem is
twofold.

1. My subform is set as a continuos form with AllowAddiotions set to NO (ie. a list of Issues to the client on the mainform)
2. To add new issues, a button is used and a pop-up form is used to add an
issue with more detail than what's available on the subform.
3. On accepting the new Issue from the pop-up the pop-up closes and you are returned to the subform, and the new line is added, but the active record is the first record and not the new one.

Problem: I have tried docmd.runcommand accmdrecordsgotolast and
docmd.GoToRecord acDataForm ,,acLast with no avail. I am getting errors
that the cmd is not available. I preface that with a requery and moving
control to the subform, either to the form itself or field on the subform,
still no luck. If I use the GoToRecord and specify the
Foms!mainform!subform as the object, I get an error that tells me the form
is not open (but it is).

Is there an easy way to move to the last record, I'm not certain what I may be doing wrong.

The second problem I am running into is I need an event to occur when I move out of a record (similar to onExit) and not into record that OnCurrent
provides. The afterupdate is of no use to me since changes may not occur.

Any help would be appreciated.

Thanks

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Alain Guichaoua | last post by:
Good evening to all Here is my problem : I have a form with a subform. They are linked. When I open the form I would like the subform to reach its last record. I tried the method...
5
by: deko | last post by:
I have a subform datasheet that contains a full year of records sorted by a date field. I'm trying to programmatically move the record selector on the datasheet to the first record that matches a...
1
by: sixsoccer | last post by:
I have built a database with a <Mainform> and a <Subform>. My problem is twofold. 1. My subform is set as a continuos form with AllowAddiotions set to NO (ie. a list of Issues to the client on...
1
by: Helmut Blass | last post by:
hi folks, I have embedded a datasheet as a subform and I want that every time the datasheet is updated, the focus be set on the last record and be visible for the user. that is like simulating...
6
by: (Pete Cresswell) | last post by:
I *know* I've seen this before but can't remember where. Got a subform - pretty simple, actually. It's lined to a work table that contains comments related to a mutual fund. No problem...
1
by: grgimpy | last post by:
This is MS Access: Is it possible to move the RecordSelectors in a subform from the main form's coding? I want to use a RecordSelectors.MoveLast type code that will move to the last record in a...
1
by: Simon | last post by:
Dear reader, How can I move the record pointer in a sub form. The sub form is a datasheet type. Both forms have the same reference key. How can I move the record pointer in the sub form...
3
by: jas2803 | last post by:
Hello, I was wondering if anyone knew how to move to the record automatically in tabular subform I have a Customer form and nested in the form I have commentary subform, tabular. More often (95%...
3
by: Lynx101 | last post by:
I am trying to move a subform onto the next record with: DoCmd.GoToRecord acForm, "MaintainAssets_edit", acNext but when I do this I get "The object 'MaintainAssets_edit' is isn't open". I...
3
by: Kan09 | last post by:
i'm having a problem with the requery and move to last command on some subforms. The subforms are used to view the data enterd into the table. I have 3 forms that use subforms. On 2 of the...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.