How to: After 24 hours, User is not allowed to Edit the Order..?

  • Thread starter cw via AccessMonster.com
  • Start date
C

cw via AccessMonster.com

This one has stumped me..
- User enters in a new Order into tblOrderProcessing and closes form
- User opens frmSearch, looks up that Order, and makes changes or adds
additional info

Question: How do I stop the user from being able to make changes to that
Order the next day (after a 24hr period)?

My frmWizard uses the tblOrderProcessing table for its main record source,
the rest are subforms on multiple tabs on that main form. I have a button on
Tab 1, that says "NEXT" which takes the User to the first editing section.

Question: What Code can I add to this NEXT button that says "Sorry, This
Order is over 24hrs old, Cannot be Edited"

Thanks,
cw
 
C

cw via AccessMonster.com

Note: I currently have the following code on that "NEXT" button:

Private Sub Command63_Click()
Me.TabCtl0 = Me.TabCtl0 + 1
End Sub
 
D

Dennis

You will need to add a date/timestamp to each record.

Then if today's date/time minus the date/timestamp of the record is > 24,
you can disable the Next command button that you added to the form.
 
D

Dennis

Alternatively (and perhaps a better solution) is to set the form's
"AllowEdits" property to "False" if the condition I described above is true.
That way, the user could step through the records, but it would be impossible
for them to change any data.
 
C

cw via AccessMonster.com

Dennis, Thanks for the quick response..
I do already have an OrdDate, have it set to default to Date()

For some reason I'm thinking way too hard on this,..?
I think this would be the idea but how exactly do I make the Date calculation
work with my Case statement below?
-----------------------------------
Private Sub Form_Load()

Dim strTimePeriod as String
strTimePeriod = ME.OrdDate - Date()

Select Case Me.strTimePeriod
Case Is <= "24"
Me.Command63.Enabled = True

Case Is > "24"
Me.Command63.Enabled = False

End Select
End Sub
----------------------------------------

You will need to add a date/timestamp to each record.

Then if today's date/time minus the date/timestamp of the record is > 24,
you can disable the Next command button that you added to the form.
Note: I currently have the following code on that "NEXT" button:
[quoted text clipped - 19 lines]
 
B

Bob Quintal

Dennis, Thanks for the quick response..
I do already have an OrdDate, have it set to default to Date()

For some reason I'm thinking way too hard on this,..?
I think this would be the idea but how exactly do I make the Date
calculation work with my Case statement below?
-----------------------------------
Private Sub Form_Load()

Dim strTimePeriod as String
strTimePeriod = ME.OrdDate - Date()

Select Case Me.strTimePeriod
Case Is <= "24"
Me.Command63.Enabled = True

Case Is > "24"
Me.Command63.Enabled = False

End Select
End Sub
First problem your strTimePeriod will return a negative number, in
days.

Second Problem, you cannot do mathetical processes (addition,
subtraction, etc) on a string.

Third Problem, using Date() instead of Now() because date() does not
have a time part.

Fourth Problem using Form_Load.event, if you can move from record to
record, you need to use the form_current event

Fifth problem, what about weekends,would you want to allow editing
monday morning of an order placed friday afternoon?

This should handle those issues.
Private Sub Form_Current()
Dim iTimePeriod as integer
iTimePeriod = datediff("h",OrdDate,Now())
If iTimeperiod < 24 Then
Me.Command63.Enabled = True
ElseIf iTimeperiod < 72 and Weekday(now(),7)<= 3 Then
Me.Command63.Enabled = True
Else
Me.Command63.Enabled = False
End If
End Sub





You will need to add a date/timestamp to each record.

Then if today's date/time minus the date/timestamp of the record
is > 24, you can disable the Next command button that you added to
the form.
Note: I currently have the following code on that "NEXT" button:
[quoted text clipped - 19 lines]
Thanks,
cw
 
C

cw via AccessMonster.com

Special Thanks to Bob and Dennis..I ended up using the code suggestion from
Bob, as user's can still print off the "Past 24 hour" Order, just not allowed
to make any changes.

Bob, Thanks for covering all of "my" bases in your code. It works perfectly
just as you posted it. I tested it by opening up an order from today, and the
Command button was Enabled. When I opened up an order from yesterday and
older ones, the Command button was Disabled each time.
Alternatively (and perhaps a better solution) is to set the form's
"AllowEdits" property to "False" if the condition I described above is true.
That way, the user could step through the records, but it would be impossible
for them to change any data.
Note: I currently have the following code on that "NEXT" button:
[quoted text clipped - 19 lines]
 
B

Bob Quintal

Special Thanks to Bob and Dennis..I ended up using the code
suggestion from Bob, as user's can still print off the "Past 24
hour" Order, just not allowed to make any changes.

Bob, Thanks for covering all of "my" bases in your code. It works
perfectly just as you posted it. I tested it by opening up an
order from today, and the Command button was Enabled. When I
opened up an order from yesterday and older ones, the Command
button was Disabled each time.

You are most welcome. I'm glad it worked perfectly, I sometimes curse
at my code several times until it works at all.
Alternatively (and perhaps a better solution) is to set the form's
"AllowEdits" property to "False" if the condition I described
above is true. That way, the user could step through the records,
but it would be impossible for them to change any data.
Note: I currently have the following code on that "NEXT" button:
[quoted text clipped - 19 lines]
Thanks,
cw
 

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