473,408 Members | 1,858 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,408 software developers and data experts.

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_BeforeUpdate(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 2371
Have you tried

DoCmd.GoToRecord , , 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*****@hotmail.com> schreef in bericht news:11**********************@g47g2000cwa.googlegr oups.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*****@hotmail.com> schreef in bericht news:11**********************@o13g2000cwo.googlegr oups.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 'beforelastcurrent' (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
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...
15
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...
0
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...
10
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...
6
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...
27
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: =!=...
0
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...
1
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...
8
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
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...

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.