UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Can I Use A Form_delete Variable In Form_afterdelconfirm?, Access 2003    
 
   
Hein
post Oct 9 2019, 11:50 AM
Post#1



Posts: 489
Joined: 10-November 05
From: The Netherlands


Hi all,

If I determine a parameter / value in sub Form_Delete, is it possible to use it in the sub Form_AfterDelconfirm?

e.g., sub Form_Delete: Description = me.txtDescription.value
If this is possible I can use the Description in a insert statement in Form_AfterDelConfirm.

At the moment I have a tempTable to put the deleted record in, and depending on the response this record is used in Form_AfterDelConfirm to insert the record in the audit table.
I would like to avoid the use of the tempTable

Can it be done?

Thanks in advance
Hein
Go to the top of the page
 
theDBguy
post Oct 9 2019, 11:54 AM
Post#2


Access Wiki and Forums Moderator
Posts: 76,416
Joined: 19-June 07
From: SunnySandyEggo


Hi Hein. One way to find out is to try. Have you and it didn't work?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Hein
post Oct 9 2019, 12:13 PM
Post#3



Posts: 489
Joined: 10-November 05
From: The Netherlands


Hi DBGuy

If have tried extensively (a lot)

I can get the values from the various controls in Form_Delete
I cannot get the values in form_delBeforeconfirm. That gives me the values of the next record (if I have 3 record with the values one, two and three and delete One, that gives me two)
If have tried to use the oldvalue but that's the same

What I have tried in beforeDelConfirm is the same as in afterDelConfirm.

I have tried to make a function to get the values and call that function in AfterDelConfirm but failed on that too (I am taking care of my mother now and i get up 4 times a night to help her, so meybe I am too tired to think clearly)

Hopefully you can put me omn the right track.

But yes, I have tried
hein
Go to the top of the page
 
theDBguy
post Oct 9 2019, 12:45 PM
Post#4


Access Wiki and Forums Moderator
Posts: 76,416
Joined: 19-June 07
From: SunnySandyEggo


Hi. I see. That's probably because the event fires after the record pointer has moved. You might have to store the value you want into a memory variable and use the Current event to put it there. Have you given that a try?

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
Hein
post Oct 9 2019, 01:03 PM
Post#5



Posts: 489
Joined: 10-November 05
From: The Netherlands


I haven't tried that so far

The (maybe incorrect) way I do it it gives me value of the new current record (delte one and the value is two)

The way I do it:
I have created a current event.
In it: dim description as variant (strings apparently can't handle null values)

Desription = me.txtDescription.value (or oldvalue)

Then I have the afterDelConfirm event
In it: msgbox description

The results are as described above (delete One and get two)

Am I doing it wrong?
Go to the top of the page
 
Hein
post Oct 9 2019, 01:34 PM
Post#6



Posts: 489
Joined: 10-November 05
From: The Netherlands


maybe I have the answer

I put an extra control (txtbox) on the form (that can be hidden)
In the delete event I fill this txtbox with the at thar time current (or should I say old) value

In the afterDelConfirm event I used the value of that textbox in a msgbox, which gave me the correct value (deleting One gives me One in the msgbox)

If I do this for every control (make a "shadow control") and use those variables/values in the afterdelconfirm event I have what I want
The last action would be to set all shadow controls back to Null

This is just a « 1 control test » but I don't see why it shouldn't work for all the others.

As many times before: you saves my day thumbup.gif
Thanks for making me think outside the box.

Hein

If you have a solution that might work better, please let me know
Go to the top of the page
 
projecttoday
post Oct 9 2019, 01:35 PM
Post#7


UtterAccess VIP
Posts: 11,082
Joined: 10-February 04
From: South Charleston, WV


What is in these records and why is it necessary to delete them?

--------------------
Robert Crouser
Go to the top of the page
 
Hein
post Oct 9 2019, 01:39 PM
Post#8



Posts: 489
Joined: 10-November 05
From: The Netherlands


I am building an audit trail, but not in the conventional way.
Not only do I want the old and new values from controls that change, I want the entire record to be visible, including the controls that stay the same.

This way I don't have to compare the current record with the changes but have it all on 1 line
If there are more than 1 changes i can filter on the ID and have the whole picture in front of me, including the dates and reasons of change.

It is for a home databse (family tree) and birthdates in partiular are prone to be different
In case of a difference of dates, again, I have the whole story in 1 press of a button

Hein
Go to the top of the page
 
tina t
post Oct 9 2019, 01:47 PM
Post#9



Posts: 6,125
Joined: 11-November 10
From: SoCal, USA


like Robert, i'm wondering if you actually need to delete the record. i have a horror of losing data, plus i've been burned a few times by managers who authorized deletion of records but then changed their minds - so i rarely delete any record from any table. instead, i have a field in most of my tables called DeletedOn, on InactivatedOn, or...whatever. the field is always a Date/Time data type. to delete a record, i simply set the value of that specific field to Now, as

Me!DeletedOn = Now

in queries, forms, reports, expressions, etc - anywhere i want to work with only active records - i use criteria to filter out "deleted" records, as

DeletedOn Is Null

hth
tina
This post has been edited by tina t: Oct 9 2019, 01:47 PM

--------------------
"the wheel never stops turning"
Go to the top of the page
 
projecttoday
post Oct 9 2019, 01:51 PM
Post#10


UtterAccess VIP
Posts: 11,082
Joined: 10-February 04
From: South Charleston, WV


Where did you get your idea? It seems to me that there is a sample audit trail db on this site or maybe another site. I've not worked with this exact thing myself.

If there is no example, another possibility is going with an unbound form.

--------------------
Robert Crouser
Go to the top of the page
 
Hein
post Oct 9 2019, 01:52 PM
Post#11



Posts: 489
Joined: 10-November 05
From: The Netherlands


I agree, but...
actually I am not deleting the records.

I am transferring the records to a different table where they will remain.
And I don't have anoying managers, the database is for personal, home use
Go to the top of the page
 
theDBguy
post Oct 9 2019, 02:01 PM
Post#12


Access Wiki and Forums Moderator
Posts: 76,416
Joined: 19-June 07
From: SunnySandyEggo


Hi Hein. Glad to hear you found a workaround. Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
projecttoday
post Oct 9 2019, 02:03 PM
Post#13


UtterAccess VIP
Posts: 11,082
Joined: 10-February 04
From: South Charleston, WV


Maybe this.

--------------------
Robert Crouser
Go to the top of the page
 
Hein
post Oct 9 2019, 02:22 PM
Post#14



Posts: 489
Joined: 10-November 05
From: The Netherlands


thanks DBGuy

I will have a lot of programming to do but I am sure that it will work out the way I like it

Now that I have found a way to do what I want, many different solutions come to mind.
It will be interesting how it turns out.

Thanks again
Hein
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    22nd October 2019 - 08:47 AM