unbound control; undo doesn't work!

S

Sag73

Hi all,

A2K3/ SQL2K/ ADP

Got a form which is bound to a SP. The aim is to be able to search for
records based on either the ID or the person name. I have therefore made
these two controls invisible and added two unbound controls which get
updated from the invisible controls by the "On Current " event. The aim of
the unbound controls is to be able to type values therein and the "Before
Update" and "After Update" events fire the search which displays the
appropriate record in the form or shows a popup form to select "near
matches" (the name is searched using 'Like %search criteria%'). Before Event
validates data entry in the unbound controls beofre allowing After Event to
perform the search and display the record if a match is found.

Problem is, if no match is found or invalid data is entered, I try to use:

Private Sub txtName_BeforeUpdate(Cancel as Integer)
If (sinlge match found) Then
(display record data in Form)
elseif (multiple matches found) then
(display selection form)
(display selected record in form)
else
Cancel=True
Me.txtName.Undo
end if

in Before Update but no matter what, the entry is not being undone in the
control. Any help greatly appreciated.
 
R

RuralGuy

AFAIK Undo does *not* work with unbound controls. It only makes sense since
what value would you expect Access to restore it to? When bound the Undo will
restore to the value in the table. You will need to roll your own Undo to get
the feature. The Tag property is available and OldValue might even be
read/write.

Hi all,

A2K3/ SQL2K/ ADP

Got a form which is bound to a SP. The aim is to be able to search for
records based on either the ID or the person name. I have therefore made
these two controls invisible and added two unbound controls which get
updated from the invisible controls by the "On Current " event. The aim of
the unbound controls is to be able to type values therein and the "Before
Update" and "After Update" events fire the search which displays the
appropriate record in the form or shows a popup form to select "near
matches" (the name is searched using 'Like %search criteria%'). Before Event
validates data entry in the unbound controls beofre allowing After Event to
perform the search and display the record if a match is found.

Problem is, if no match is found or invalid data is entered, I try to use:

Private Sub txtName_BeforeUpdate(Cancel as Integer)
If (sinlge match found) Then
(display record data in Form)
elseif (multiple matches found) then
(display selection form)
(display selected record in form)
else
Cancel=True
Me.txtName.Undo
end if

in Before Update but no matter what, the entry is not being undone in the
control. Any help greatly appreciated.

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
S

Sag73

Thanks for that RuralGuy and sorry I did not realise that.
I haven't had a lot of success with OldValue but I'll try to investigate.
 
V

Vadim Rapp

Hello RuralGuy:
You wrote on Sun, 02 Oct 2005 04:59:28 -0600:

R> AFAIK Undo does *not* work with unbound controls. It only makes sense
R> since what value would you expect Access to restore it to? When bound
R> the Undo will restore to the value in the table. You will need to roll
R> your own Undo to get the feature. The Tag property is available and
R> OldValue might even be read/write.

without even looking, I bet oldvalue won't work for the same reasons as you
mentioned.

Vadim
 
R

RuralGuy

Thanks Vadim,
You got me curious so I did some testing. OldValue is Read Only in all views
whether the control is bound or not. When the control is UnBound then OldValue
follows Value. So you are correct that OldValue will not work here. But the
Tag property is still available and would work for rolling your own UnDo.

Hello RuralGuy:
You wrote on Sun, 02 Oct 2005 04:59:28 -0600:

R> AFAIK Undo does *not* work with unbound controls. It only makes sense
R> since what value would you expect Access to restore it to? When bound
R> the Undo will restore to the value in the table. You will need to roll
R> your own Undo to get the feature. The Tag property is available and
R> OldValue might even be read/write.

without even looking, I bet oldvalue won't work for the same reasons as you
mentioned.

Vadim

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
S

Sag73

Hi Vadim & RG

Well I guess your analysis / presumption are correct. However, RG's pointer
on trying to use OldValue has helped me.

As the unbound controls derive their value from the bound controls, I have
used the OldValue of the bound controls to 'roll-back' the value of the
unbound controls when no search criterion is met.

Thanks for pointing me in the good direction.
 
R

RuralGuy

That's what I like to hear, success! Good Job.

Hi Vadim & RG

Well I guess your analysis / presumption are correct. However, RG's pointer
on trying to use OldValue has helped me.

As the unbound controls derive their value from the bound controls, I have
used the OldValue of the bound controls to 'roll-back' the value of the
unbound controls when no search criterion is met.

Thanks for pointing me in the good direction.

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 
V

Vadim Rapp

Hello RuralGuy,
You wrote in conference
microsoft.public.access.adp.sqlserver,microsoft.public.access.forms,microsoft.public.access.formscoding
on Mon, 03 Oct 2005 20:34:55 -0600:


VR> without even looking, I bet oldvalue won't work for the same
VR> reasons as you mentioned.

R> You got me curious so I did some testing.

which means you accepted the bid. As an old mainframe game was saying 25
years ago, "you lost $10, please put them into the punchcard reader".

:)))
 
R

RuralGuy

lol, you caught me. $'s inserted.

Hello RuralGuy,
You wrote in conference
microsoft.public.access.adp.sqlserver,microsoft.public.access.forms,microsoft.public.access.formscoding
on Mon, 03 Oct 2005 20:34:55 -0600:


VR> without even looking, I bet oldvalue won't work for the same
VR> reasons as you mentioned.

R> You got me curious so I did some testing.

which means you accepted the bid. As an old mainframe game was saying 25
years ago, "you lost $10, please put them into the punchcard reader".

:)))

_______________________________________________
hth - RuralGuy (RG for short)
Please post to the NewsGroup so all may benefit.
 

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