Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

beforeUpdate event

Status
Not open for further replies.

djam

Technical User
Nov 15, 2002
223
0
0
CA
how can i make the beforeUpdate event trigger even if no data was changed on the form?

i've tried this in the on_current

dim temp as string
temp = me.firstName
me.firstName = ""
me.firstName = temp

this works for a little bit but then I get a error
run-time error '-2147352567(80020009)':
The data has been changed.

I need to do this bc I'm parsing a phone number into separate fields for the interface, if the user changes on the phone number and goes to another record, the beforeUpdate event does not trigger

thanks "so many events, so little time"
 
why use the beforeupdate in your case i wouldsuggest in the afterupdate of the phonenumber textbox. the on current event will only execute in the next record not in the one he has just changed. and BTW try refferencing to the textbox not the field. "What a wonderfull world" - Louis armstrong
 
If I'm understanding your situation correctly...

Assuming you know where you want the BeforeUpdate event code to execute (e.g. in the OnCurrent event code), you can simply call the BeforeUpdate event sub by name, like any other function or subroutine. Like this:

Private Sub Form_Current(Cancel As Integer)
'"Trigger" the BeforeUpdate event...
Call Form_BeforeUpdate
End Sub

NOTE: the keyword "Call" is optional. The sub will execute just the same with the word "Call" omitted.

 
Form_current only executes at the start of the next record, it does not execute at the end of the record. I need before_update to execute no matter what, when goin from record to record. It only executes if there was a change to one of the attributes.

"so many events, so little time"
 
Pduke has the right answer.

you just need to add the line

"Form_BeforeUpdate"

anywhere in your VB code to run the BeforeUpdate funciton, it doesnt have to be in the Form_Current event. Just add it wherever you need it (eg: The AfterUpdate even on all of your forms text boxes)
 
I've implemented something in the afterupdate event on the text boxes. There was a Oracle database error which was causing the problem and made me think that my code was not correct (when it was correct) argggg..... The Oracle dba has fixed the problem... well hopefully. "so many events, so little time"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top