Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / March 2005

Tip: Looking for answers? Try searching our database.

Code for reversing procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andi Lee Davis - 02 Mar 2005 16:27 GMT
I have an event procedure that when you click a check box it puts a date in
another box like so

Private Sub CallClosed_Click()

If Me!CallStatus = "RF1" Then Me!CallStatus = "RF2"
If Me!CallStatus = "RF4" Then Me!CallStatus = "RF5"
If Me!CallStatus = "C" Then Me!CallStatus = "M"
If Me!CallStatus = "Other" Then Me!CallStatus = "M"
Me!DATECLOSED = Date

   With [Forms]![OrdersToshiba]![OrderDetails].[Form].RecordsetClone
       .MoveFirst
       Do While .EOF = False
           .Edit
           If ![GoodsReceived] = False Then ![GoodsReceived] = True Else
![GoodsReceived] = True
           If ![GoodsReceivedDate] <> Date Then ![GoodsReceivedDate] =
![GoodsReceivedDate] Else ![GoodsReceivedDate] = Date
           .Update
           .MoveNext
       Loop
   End With

End Sub

however I want this proccess to apply if the value of the checkbox changes
from False to True and the opposite for True to False .
How would i reverse this process?

I have tried On true and On false commands however is not really working.

Thanks

Andi
Mike Painter - 02 Mar 2005 18:07 GMT
> I have an event procedure that when you click a check box it puts a
> date in another box like so
[quoted text clipped - 6 lines]
> If Me!CallStatus = "Other" Then Me!CallStatus = "M"
> Me!DATECLOSED = Date

A select Case statement would serve better here and the "ELSE" part can
catch errors.
What happenes if Me!Call Status = "Next Tuesday"?

>    With [Forms]![OrdersToshiba]![OrderDetails].[Form].RecordsetClone
>        .MoveFirst
[quoted text clipped - 10 lines]
>
> End Sub
A query would be much faster here. Maybe not noticable with a few records
but worth doing.

> however I want this proccess to apply if the value of the checkbox
> changes from False to True and the opposite for True to False .
[quoted text clipped - 4 lines]
> If Me!CallStatus = "C" Then Me!CallStatus = "M"
> If Me!CallStatus = "Other" Then Me!CallStatus = "M"

Reversing the first two is simply a matter of  placing the opposite of them
in the Else part of an If statement
IF CHECKBOX then
    If Me!CallStatus = "RF1" Then Me!CallStatus = "RF2"
    If Me!CallStatus = "RF4" Then Me!CallStatus = "RF5"
    If Me!CallStatus = "C" Then Me!CallStatus = "M"
    If Me!CallStatus = "Other" Then Me!CallStatus = "M"
ELSE
    If Me!CallStatus = "RF2" Then Me!CallStatus = "RF1"
    If Me!CallStatus = "RF5" Then Me!CallStatus = "RF4"
End If

You can only change the "M" value back to one value unless there is
something else that distinguishes "C" from "Other"
Andi Lee Davis - 04 Mar 2005 09:17 GMT
hi Mike,

Thanks for your valuable response. In answer to your question I shall try
with an update query.
In answer to your questions

1) What happenes if Me!Call Status = "Next Tuesday"? - This will never be,
the status is imported in from another database and refers to fixed criteria.
Although you can type in any stutus you want after. however I have a combo
box with the selection as avalue list. The status is designed to identify and
filter service calls by their status so this is fixed. Either RF1 (open) or
RF2 (closed), RF4 (Not urgent open), RF5 (Not urgent closed)

2) You can only change the "M" value back to one value unless there is
something else that distinguishes "C" from "Other"  - I am not worried about
these status remaining like this. The ones we are interested in catching are
RF1, RF2 etc.

3) I am not sure what  "A select Case statement" is when you mentioned - "A
select Case statement would serve better here and the "ELSE" part can catch
errors."

Thanks once again - Andi

> > I have an event procedure that when you click a check box it puts a
> > date in another box like so
[quoted text clipped - 51 lines]
> You can only change the "M" value back to one value unless there is
> something else that distinguishes "C" from "Other"
Andi Lee Davis - 04 Mar 2005 09:49 GMT
Hi Mike,

In reference to doing an update Query, the VB is better, because I have
included a variant on the Else Statement for reversing it. - I now have this.
The dates are either removed or added against the subform lines if it is
todays date. So if you accidently close the call, it can now be reversed
without touching any information appended previously etc...

Thanks again for your help.

Andi

Private Sub CallClosed_Click()

If CallClosed Then
   
   If Me!CallStatus = "RF1" Then Me!CallStatus = "RF2"
   If Me!CallStatus = "RF4" Then Me!CallStatus = "RF5"
   If Me!CallStatus = "C" Then Me!CallStatus = "M"
   If Me!CallStatus = "Other" Then Me!CallStatus = "M"
   Me!DATECLOSED = Date
   
   With [Forms]![OrdersNonTosh]![OrderDetails].[Form].RecordsetClone
       .MoveFirst
       Do While .EOF = False
           .Edit
           If ![GoodsReceived] = False Then ![GoodsReceived] = True Else
![GoodsReceived] = True
           If ![GoodsReceivedDate] <> Date Then ![GoodsReceivedDate] =
![GoodsReceivedDate] Else ![GoodsReceivedDate] = Date
           .Update
           .MoveNext
       Loop
   End With
   
Else
   If Me!CallStatus = "RF2" Then Me!CallStatus = "RF1"
   If Me!CallStatus = "RF5" Then Me!CallStatus = "RF4"
   Me!DATECLOSED = Null
   
   With [Forms]![OrdersNonTosh]![OrderDetails].[Form].RecordsetClone
       .MoveFirst
       Do While .EOF = False
           .Edit
           ![GoodsReceived] = False
           If ![GoodsReceivedDate] = Date Then ![GoodsReceivedDate] = Null
Else ![GoodsReceivedDate] = ![GoodsReceivedDate]
           .Update
           .MoveNext
       Loop
   End With
       
End If

End Sub
Mike Painter - 05 Mar 2005 00:13 GMT
> Hi Mike,
>
[quoted text clipped - 6 lines]
>
> Thanks again for your help.

As long as you are dealing with only a few records or don't mind waiting
there is nothing wrong with writing a *lot* of code that can be handled with
a simple query or two and be much easier to maintain.

More than 20 years ago I stopped assuming that there were any "can't happen"
situations. What if the information from the other system changes, there is
an error in the data or somebody changes it on the form. The Else part of
the CASE statement (found in vb help) can warn of such errors.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.