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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete last entry button

Status
Not open for further replies.

696796

Programmer
Joined
Aug 3, 2004
Messages
218
Location
GB
Hi,

i want to create a button on screen which will delete or undo the last input to a field. I have tried me.undo but i think this deletes the whole record??

If possible, the button will delete the field according to where the curser lies. Basically a button on form which replicates the action of the delete key on a keyboard.

You may ask why this is neccessary - i'm developing a database (access97) to be used on touchscreens, so no keyboards allowed!

I did try searching old posts but didn't find what i needed so ive posted this new one.

Thanks for any help, v.much apreciated,

Regards,

Alex
 
It may not be practical depending on how many fields you have. Messy code but it would work. Suppose for simplicities sake you have 3 fields. TB1, TB2 and TB3.

Somewhere declare a variable:

Dim lastedit as string

Then for each textbox, something like,

Private Sub TB1_AfterUpdate()
set lastedit = "TB1"
End Sub


Then:

Private Sub Delete_Click()
If lastedit="TB1" then
TB1.setfocus
Elseif lastedit="TB2" then
TB2.setfocus
Elseif lastedit="TB3" then
TB3.setfocus
End If
SendKeys ("{F2}")
SendKeys ("{BACKSPACE}")
End Sub


Laborious and not pretty but it would do the job.
 
Came across this code while looking for something else I dont now if it works never tried it so no promises but was on a button

Screen.PreviousControl.SetFocus
DoCmd.FindNext

Hope this helps
Hymn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top