Return original value

G

Guest

I need some help in returning the value of a text box following the OnExit
Event.

I have a text box [AssignedTo] that has a default value pulled from a table
not related to the form.

I am using a DoCmd.SQL Update statement if the user selects OK to accept the
change.

However, if they cancel, I need to return the text box to the default value.

If have tried....


Me.AssignedTo.Undo

and

Me.Requery (because of the rules around other required fields, this won't
work without causing error messages)

Any ideas would be appreciated.

Cheers
 
G

Graham Mandeno

Hi Paul

If AssignedTo is a bound textbox, then .Undo should return it to its
original value *unless* the record has been saved in the meantime.

Are you sure that (a) the textbox is bound and (b) the record is still dirty
from the user changing the value?
 
G

Guest

Hi Graham,

The text box is unbound. As far as being dirty, I thought using the OnExit
event would allow me to capture whether or not the user actually wanted to
change to value (not normally done for this field, but there as an option).

Thanks.


Graham Mandeno said:
Hi Paul

If AssignedTo is a bound textbox, then .Undo should return it to its
original value *unless* the record has been saved in the meantime.

Are you sure that (a) the textbox is bound and (b) the record is still dirty
from the user changing the value?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

Paul B. said:
I need some help in returning the value of a text box following the OnExit
Event.

I have a text box [AssignedTo] that has a default value pulled from a
table
not related to the form.

I am using a DoCmd.SQL Update statement if the user selects OK to accept
the
change.

However, if they cancel, I need to return the text box to the default
value.

If have tried....


Me.AssignedTo.Undo

and

Me.Requery (because of the rules around other required fields, this won't
work without causing error messages)

Any ideas would be appreciated.

Cheers
 
G

Graham Mandeno

Hi Paul

If the textbox is unbound, then you must save the original value and restore
it yourself.
Me.AssignedTo = strOriginalAssignedTo

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Paul B. said:
Hi Graham,

The text box is unbound. As far as being dirty, I thought using the OnExit
event would allow me to capture whether or not the user actually wanted to
change to value (not normally done for this field, but there as an
option).

Thanks.


Graham Mandeno said:
Hi Paul

If AssignedTo is a bound textbox, then .Undo should return it to its
original value *unless* the record has been saved in the meantime.

Are you sure that (a) the textbox is bound and (b) the record is still
dirty
from the user changing the value?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

Paul B. said:
I need some help in returning the value of a text box following the
OnExit
Event.

I have a text box [AssignedTo] that has a default value pulled from a
table
not related to the form.

I am using a DoCmd.SQL Update statement if the user selects OK to
accept
the
change.

However, if they cancel, I need to return the text box to the default
value.

If have tried....


Me.AssignedTo.Undo

and

Me.Requery (because of the rules around other required fields, this
won't
work without causing error messages)

Any ideas would be appreciated.

Cheers
 
G

Guest

Thanks Graham,

Can you provide more details as to how to do this. I am having a little
difficulty wrapping my head around variables, when to use them etc. If you
could give me a sample as to when to save a variable prior to the user
actually attempting to make the change, it would help me understand the
process.

Thanks again.

Graham Mandeno said:
Hi Paul

If the textbox is unbound, then you must save the original value and restore
it yourself.
Me.AssignedTo = strOriginalAssignedTo

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Paul B. said:
Hi Graham,

The text box is unbound. As far as being dirty, I thought using the OnExit
event would allow me to capture whether or not the user actually wanted to
change to value (not normally done for this field, but there as an
option).

Thanks.


Graham Mandeno said:
Hi Paul

If AssignedTo is a bound textbox, then .Undo should return it to its
original value *unless* the record has been saved in the meantime.

Are you sure that (a) the textbox is bound and (b) the record is still
dirty
from the user changing the value?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

I need some help in returning the value of a text box following the
OnExit
Event.

I have a text box [AssignedTo] that has a default value pulled from a
table
not related to the form.

I am using a DoCmd.SQL Update statement if the user selects OK to
accept
the
change.

However, if they cancel, I need to return the text box to the default
value.

If have tried....


Me.AssignedTo.Undo

and

Me.Requery (because of the rules around other required fields, this
won't
work without causing error messages)

Any ideas would be appreciated.

Cheers
 
G

Graham Mandeno

Hi again Paul

How are you getting the value in there in the first place? Is it the
default value?

If so, then you could say:
AssignedTo = AssignedTo.DefaultValue

If not (say you're loading the value in the Form_Load or Form_Current event
procedure) you could either save the value in a module-level variable:

<declarations section>
Dim mstrOriginalAssignedTo as String

<Form_Load>
mstrOriginalAssignedTo = <some string expression>
AssignedTo = mstrOriginalAssignedTo

<code where you want to undo>
AssignedTo = mstrOriginalAssignedTo

Or, you could store the original value in the control's Tag property:
AssignedTo.Tag = <some string expression>
...
AssignedTo = AssignedTo.Tag
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Paul B. said:
Thanks Graham,

Can you provide more details as to how to do this. I am having a little
difficulty wrapping my head around variables, when to use them etc. If you
could give me a sample as to when to save a variable prior to the user
actually attempting to make the change, it would help me understand the
process.

Thanks again.

Graham Mandeno said:
Hi Paul

If the textbox is unbound, then you must save the original value and
restore
it yourself.
Me.AssignedTo = strOriginalAssignedTo

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Paul B. said:
Hi Graham,

The text box is unbound. As far as being dirty, I thought using the
OnExit
event would allow me to capture whether or not the user actually wanted
to
change to value (not normally done for this field, but there as an
option).

Thanks.


:

Hi Paul

If AssignedTo is a bound textbox, then .Undo should return it to its
original value *unless* the record has been saved in the meantime.

Are you sure that (a) the textbox is bound and (b) the record is still
dirty
from the user changing the value?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

I need some help in returning the value of a text box following the
OnExit
Event.

I have a text box [AssignedTo] that has a default value pulled from
a
table
not related to the form.

I am using a DoCmd.SQL Update statement if the user selects OK to
accept
the
change.

However, if they cancel, I need to return the text box to the
default
value.

If have tried....


Me.AssignedTo.Undo

and

Me.Requery (because of the rules around other required fields, this
won't
work without causing error messages)

Any ideas would be appreciated.

Cheers
 
G

Guest

Thanks Graham,

This is a big help.

To answer your question, the value is a default, using DLast to pull to
current value from the table 'tblVehicles'. I tried your first suggestion,
and what Access 97 is doing is copying the DLast string into the forms field.
But hey, at least it's a start, I'll try to work this out myself.

The other suggestions are areas that I have not ventured yet, so if I can't
get your first suggestion to work, I'll try the others.

Cheers


Graham Mandeno said:
Hi again Paul

How are you getting the value in there in the first place? Is it the
default value?

If so, then you could say:
AssignedTo = AssignedTo.DefaultValue

If not (say you're loading the value in the Form_Load or Form_Current event
procedure) you could either save the value in a module-level variable:

<declarations section>
Dim mstrOriginalAssignedTo as String

<Form_Load>
mstrOriginalAssignedTo = <some string expression>
AssignedTo = mstrOriginalAssignedTo

<code where you want to undo>
AssignedTo = mstrOriginalAssignedTo

Or, you could store the original value in the control's Tag property:
AssignedTo.Tag = <some string expression>
...
AssignedTo = AssignedTo.Tag
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Paul B. said:
Thanks Graham,

Can you provide more details as to how to do this. I am having a little
difficulty wrapping my head around variables, when to use them etc. If you
could give me a sample as to when to save a variable prior to the user
actually attempting to make the change, it would help me understand the
process.

Thanks again.

Graham Mandeno said:
Hi Paul

If the textbox is unbound, then you must save the original value and
restore
it yourself.
Me.AssignedTo = strOriginalAssignedTo

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Hi Graham,

The text box is unbound. As far as being dirty, I thought using the
OnExit
event would allow me to capture whether or not the user actually wanted
to
change to value (not normally done for this field, but there as an
option).

Thanks.


:

Hi Paul

If AssignedTo is a bound textbox, then .Undo should return it to its
original value *unless* the record has been saved in the meantime.

Are you sure that (a) the textbox is bound and (b) the record is still
dirty
from the user changing the value?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

I need some help in returning the value of a text box following the
OnExit
Event.

I have a text box [AssignedTo] that has a default value pulled from
a
table
not related to the form.

I am using a DoCmd.SQL Update statement if the user selects OK to
accept
the
change.

However, if they cancel, I need to return the text box to the
default
value.

If have tried....


Me.AssignedTo.Undo

and

Me.Requery (because of the rules around other required fields, this
won't
work without causing error messages)

Any ideas would be appreciated.

Cheers
 
G

Guest

Got it....

Took your suggest and put the following in the OnEXit event after the
MsgBox....


AssignedTo = DLast ("[AssignedTo]", "tblVehicle", [VheicleNumber] ="_
& [VehicleNumber])

Thanks again, examples like yours work best for me, I could have read
everybook I have and not found the answer.

Cheers


Paul B. said:
Thanks Graham,

This is a big help.

To answer your question, the value is a default, using DLast to pull to
current value from the table 'tblVehicles'. I tried your first suggestion,
and what Access 97 is doing is copying the DLast string into the forms field.
But hey, at least it's a start, I'll try to work this out myself.

The other suggestions are areas that I have not ventured yet, so if I can't
get your first suggestion to work, I'll try the others.

Cheers


Graham Mandeno said:
Hi again Paul

How are you getting the value in there in the first place? Is it the
default value?

If so, then you could say:
AssignedTo = AssignedTo.DefaultValue

If not (say you're loading the value in the Form_Load or Form_Current event
procedure) you could either save the value in a module-level variable:

<declarations section>
Dim mstrOriginalAssignedTo as String

<Form_Load>
mstrOriginalAssignedTo = <some string expression>
AssignedTo = mstrOriginalAssignedTo

<code where you want to undo>
AssignedTo = mstrOriginalAssignedTo

Or, you could store the original value in the control's Tag property:
AssignedTo.Tag = <some string expression>
...
AssignedTo = AssignedTo.Tag
--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand


Paul B. said:
Thanks Graham,

Can you provide more details as to how to do this. I am having a little
difficulty wrapping my head around variables, when to use them etc. If you
could give me a sample as to when to save a variable prior to the user
actually attempting to make the change, it would help me understand the
process.

Thanks again.

:

Hi Paul

If the textbox is unbound, then you must save the original value and
restore
it yourself.
Me.AssignedTo = strOriginalAssignedTo

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Hi Graham,

The text box is unbound. As far as being dirty, I thought using the
OnExit
event would allow me to capture whether or not the user actually wanted
to
change to value (not normally done for this field, but there as an
option).

Thanks.


:

Hi Paul

If AssignedTo is a bound textbox, then .Undo should return it to its
original value *unless* the record has been saved in the meantime.

Are you sure that (a) the textbox is bound and (b) the record is still
dirty
from the user changing the value?

--
Graham Mandeno [Access MVP]
Auckland, New Zealand

I need some help in returning the value of a text box following the
OnExit
Event.

I have a text box [AssignedTo] that has a default value pulled from
a
table
not related to the form.

I am using a DoCmd.SQL Update statement if the user selects OK to
accept
the
change.

However, if they cancel, I need to return the text box to the
default
value.

If have tried....


Me.AssignedTo.Undo

and

Me.Requery (because of the rules around other required fields, this
won't
work without causing error messages)

Any ideas would be appreciated.

Cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top