473,398 Members | 2,403 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,398 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 22919
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.