Inactive delete feature

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a .db that tracks computer equipment. On one of my forms I currently
have a command button that is setup to delete records. I no longer want to
delete them but instead make them inactive so I created another cmd button
that when depressed will inactivate them rather than delete. I created an
inactive checkbox and two other fields that when the checkbox is checked it
automatically populates the fields with the date and current user. What I
would like to do if possible is have the delete cmd button disabled after it
is pressed once that way it can't be accidently undeleted by mistake. Or
even make the whole record locked. What would be the code that I can put
behind the button in order to do this or can this even be done?

I also have added a toggle button to the form that I would like to apply a
filter so that I can see active or inactive by toggling the button but I'm
not sure how to do this. Would I need to add code on click on the button.

Any help would be appreciated.
 
This will deactivate your delete button
btnDelete.Active = false
I also have added a toggle button to the form that I would like to apply a
filter so that I can see active or inactive by toggling the button but I'm
not sure how to do this. Would I need to add code on click on the button.

I am assumming:
1 - Your data is in a SubForm
2 - Toggle option 1: "Active", value =1 option 2: "Inactive", value =
anything else

SubForm1.Form.Filter = "Active = " & iif(Toggle1=1, "True", "False")
SubForm1.Form.FilterOn = True

If you data is in the same form, use
Me.Filter = "Active = " & iif(Toggle1=1, "True", "False")
Me.FilterOn = True

Take care
Mauricio Silva
 
Thanks for your help. My data is in the same form.

Am I supposed to create 2 toggle buttons, one for active and the other
inactive? If so where would I put the following information:

Toggle option 1: "Active", value =1 option 2: "Inactive"

Where do I assign it a value, in the properties of the button? Do I need
two toggle buttons? An active one and and Inactive one, so when the active
button is pressed it will show the records where the yes/no check box has not
been checked off and the opposite for the Inactive btn.

Is this the easiest way to do this, any suggestions would be appreciated.

Thanks
 
It seems to be easier for your to create an Option Group, following the wizard:
- Define two option: Active and Inactive.
- Choose your default choice: Active
- Assign values: Active = 1 Inactive = 2
- Choose: Save the value for later use
- Select toogle buttons
- Choose a caption: suggestion : Filter

In the event After_Update insert the commands:

Private Sub Frame1_AfterUpdate()
Me.Filter = "Active = " & IIf(Frame1 = 1, "True", "False")
Me.FilterOn = True
End Sub

Obs.: Change Frame1 for the name of your new frame (Option Group object)

I think this is what your are looking for.

Take Care
Mauricio Silva
 
So I created the option group and added to code to the After_Update event.

But when I open the form and click on InActive or Active toggle buttons I
get a box asking me to Enter a Parameter Value for Active. When it asks me
to debug it points to the Me.FilterOn = True line.

I don't understand how these buttons tie to my yes/no field that displays
whether the record is active or not?
 
Sorry, my fault

it is asking for a value for Active parameter because the field active
doesn't exist. In the line:

Me.Filter = "Active = " & IIf(Frame1 = 1, "True", "False")

you also need to change the word Active to the name of your yes/no field

Mauricio Silva
 
Thanks, that worked great. The only thing is that the Active toggle button
displays the inactive records and the Inactive toggle button displays the
active ones. Is there any way to reverse this.

Also is there an easy way to add another toggle button that will display all
records. I find once you click on Active for example you can no longer see
all the records anymore. Maybe I should have Active, Inactive and All.

Thanks again for the help.
 
You just need to click in the toggle button at the toolbox and create it
directly inside the frame. It will be directly conected to de others toggle
button with the optionvalue = 3

You also will have to change the AfterUpdate code to:

if (Frame1.Value = 3 ) then
me.Filter = ""
else
Me.Filter = "Active = " & IIf(Frame1 = 1, "True", "False")
end if

Me.filteron = true

Remenber to change the name of the frame1 and Active field
P.S. To correct the Active/Inactive reverse the true/false options
----
I'll tell you how I usually do when I have more than 2 options:
I create a combobox and assign the parameters:
Row Source Type = Value List
Row Source = 1;"Active";2;"Inactive";3;"All records"
Cound Column = 1
Limit to List = Yes
Column Count = 2
ColumnWidths = 0;1

Event AfterUpdate:

Select Case Combo01
Case 01: Me.filter = "Active = True"
Case 02: Me.filter = "Active = False"
Case 03: Me.filter = ""
End Select

me.FilterOn = true

Notes:
- Change Combo1 for the combo name
- Change Actiev for yes/No field name

Take Care

Mauricio Silva
 
Back
Top