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

Home Posts Topics Members FAQ

determining next record in BeforeUpdate event

Hello,

I am trying to bypass a form's automatic update, and instead call a
stored procedure in sql server. I am using continuous forms. The
problem I am having is with returning to the next selected record once
I have performed the update.

i.e. user edits record A and then clicks on record B. Record A is
updated, and selection moves to record B. I don't know how to
determine what record B is...

The best that I am able to achieve so far is listed in my code below.
This returns to the most recently updated record once the update is
performed. Here's the gist of my code in the BeforeUpdate event:
Private Sub Form_BeforeUpda te(Cancel As Integer)

...code to manually call an update stored procedure

' bookmark record A position
vntBookmark = form.bookmark

' refresh form
Form.Undo ' this stops the regular update process from occuring
Form.Refresh ' this requery's the db so that the updates are visible.

' go to saved position
Form.Bookmark = vntBookmark

end Sub

The above code returns to record A after the refresh. Does anybody
have any suggestions on how to bookmark the "next" selected record
(record B)?

Any solutions/suggestions would be greatly appreciated.

Thanks,

Todd

Nov 13 '05 #1
7 2389
Have you tried

DoCmd.GoToRecor d , , acNext

?

Nov 13 '05 #2
That's a good idea, but the next record the user selected isn't
necessarily the next record on the form. Any other ideas?

Nov 13 '05 #3
Something I should probably mention to make things clearer is that the
record position is lost when a form.refresh command is given. This is
what creates the problem of determining which record the user clicked
on to initiate the beforeUpdate event.

Nov 13 '05 #4

"Todd" <to*****@hotmai l.com> schreef in bericht news:11******** **************@ g47g2000cwa.goo glegroups.com.. .
Something I should probably mention to make things clearer is that the
record position is lost when a form.refresh command is given. This is
what creates the problem of determining which record the user clicked
on to initiate the beforeUpdate event.

You have a unique id value in the record I guess?
Store the value (on current) in a var, and go back to (find) the record if needed.

Arno R

Nov 13 '05 #5
I do have a unique ID associated with each record but the problem with
that solution is that the form_current event actually occurs after the
beforeupdate event. If I were to move the form.refresh statement to
the form_current event I would encounter the problem of being stuck on
the record that is being updated (form.undo would keep me stuck in the
edited record). Thanks for the suggestion. Any other ideas?

Nov 13 '05 #6

"Todd" <to*****@hotmai l.com> schreef in bericht news:11******** **************@ o13g2000cwo.goo glegroups.com.. .
I do have a unique ID associated with each record but the problem with
that solution is that the form_current event actually occurs after the
beforeupdate event. If I were to move the form.refresh statement to
the form_current event I would encounter the problem of being stuck on
the record that is being updated (form.undo would keep me stuck in the
edited record). Thanks for the suggestion. Any other ideas?

I don't think I grasp what's happening here (what you are trying to do...)
I *do* think you will have to store the ID, one way or another.
- Use a var 'lastclicked' if the user really 'clicks' in a new record.
- Or use two vars: 'lastcurrent' and 'beforelastcurr ent' (beforelast.. get's it's value from the last..)
But again, I am not sure this is what you need...

Arno R
Nov 13 '05 #7
I think you are on the right track. The problem is determining the ID
of the record the user clicked on. The hitch is that all of the events
(that I tried) occur after the beforeupdate event, so there's no way of
actually recording the ID before I screw things up by running a
form.undo and form.refresh. The undo and refresh are necessary (I
think) for me to bypass the regular update procedure, and call my
stored procedure instead. I hope this explanation helps clarify.

Nov 13 '05 #8

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

Similar topics

3
4747
by: William Wisnieski | last post by:
Hello Everyone, Access 2000, I have a main unbound form with a bound datasheet subform . The subform is bound to a query that returns records based on criteria in the main form. The user then double clicks a row on the datasheet subform to open yet another form bound to a table . These two forms are linked by the field. So far so good.
15
11252
by: Susan Bricker | last post by:
Greetings. I have a Mainform with a subform. The Mainform has single record format and subform has continuous form format. When the Mainform opens, I force allowadditions and allowedits to FALSE (for both the Mainform and Subform). No problem there. However, when I click on the navigation control of the subform to move to the next record in the subform, the AllowAdditions and AllowEdits changes to TRUE. Not good. I set...
0
1645
by: Deano | last post by:
My beforeupdate event on the main form fires when a change has been made and the record has not been saved (2 variables are used to track this). Works great but if they make a change in my subform which is in one tab of a tab control, and then they select a different tab, the beforeupdate event fires. So they get prompted as to whether they want to save the record - however the idea is that the event only fires if they try to close the...
10
2292
by: MLH | last post by:
Would like to examine the value entered into a textbox on an A97 form during the BeforeUpdate event. The textbox may or may not have had an earlier entry in it prior to the latest value that is now in the process of being entered. What's the best way to refer to the value just typed that is about to update the textbox?
6
3122
by: lorirobn | last post by:
Hi, I have a form with a continuous subform. I am working on putting validations in for the subform's required fields. Being somewhat new to Access (or rather, an antiquated mainframe programmer), I finally figured out that the place to put the validations is in Form_BeforeUpdate. I have 2 questions: 1) once I determine there is an error and display a message box with
27
3944
by: Kim Webb | last post by:
I have a field on a form for project number. I basically want it to be the next available number (ie 06010 then 06011 etc). In the form I create a text box and under control source I put: =!= This does not work I tried:
0
1756
by: adolph | last post by:
Hi, I have a beforeupdate evbent that tests to see that a customer chosen before the user can enter an amount. If the customer has not been chosen yet, then I would like to popup a message informing the user to first choose a customer. After the user has clicked on OK, I want the code to undo the amount field and set focus to a field in a subform where the user can then type in a customer nasme. Using the code below, I get the 2108 error....
1
1835
by: chuaby | last post by:
Hi I have a generic form to keep data. I.e, date, number, string all are stored as TEXT in different rows in a same table. i would like to validate that the date is in a correct format. The different rows appear in the 'Detailed" section. May i know how do i prevent the "focus" to jump to the next row if there is a validation error until it conforms to my requirement. I have tried using GotoRecord but it does not give the kind of...
8
66863
by: evn678 | last post by:
Hello all, I am trying to handle a scenario where a user clicks the 'X' close control on a form window border. I want to force the user to use the form's 'save' button to write the updated record. (If the form is not dirty, the 'X' control will just close it silently.) In the BeforeUpdate event I ask the user if they want to discard their changes (this code is skipped if the user *actually* pressed the save button). If the user answers...
0
8403
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
8833
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8737
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
8610
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...
0
5636
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
4168
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
4327
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2735
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1730
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.