Date based coding

L

Lori

Need a little help. I have a form that the users use to enter in vacation
days onto a calendar. What I would like to do is allow them to make changes
to this calendar but prevent them from changing things after the fact.
Example if they were scheduled off on 11-16 they must change details for that
date on or prior to the 16th.

Is this possible?
 
C

Crystal (strive4peace)

Hi Lori,

to validate a record and prevent it from being saved, put
code in the form BeforeUpdate event

'----------------- make sure all required data is filled

'make sure SomeControlName is filled out
If IsNull(me.SomeControlName) then

'if it is not filled out,
'then move the focus to that control
me.SomeControlName.setFocus

'give the user a message
msgbox "You must enter Some Data",,"Missing Data"

'if this is a combobox, drop the list for them
me.SomeControlName.dropDown

'don't save the record yet
Cancel = true

'quit checking and give them a chance to fill it out
exit sub
end if

'make sure the first Date is filled out
If IsNull(me.[Date1]) then
me.[Date1].setFocus
msgbox "You must enter the first Date" _
,,"Missing Data"
Cancel = true
exit sub
end if

'make sure the second Date is filled out
If IsNull(me.[Date2]) then
me.[Date2].setFocus
msgbox "You must enter the second date" _
,,"Missing Data"
Cancel = true
exit sub
end if

'make sure the second Date is >= Date1
If me.[Date2] < me.[Date1] then
me.[Date2].setFocus

msgbox "The second date, " & me.Date2 _
& " must be >= the first date, " _
& me.[Date1],,"Invalid Data"
Cancel = true

'IF you want to undo the entries to the record
'Me.Undo

'IF you want to undo the entries to the field
'Me.controlname.Undo
Cancel = true
exit sub
end if

'~~~~~~~~~~~~~~~~~~~~

these are generic instructions -- to customize this for your
situation, you can do this:

If me.[Date_controlname] > Date() then



Warm Regards,
Crystal
remote programming and training
http://MSAccessGurus.com

free video tutorials
http://www.YouTube.com/user/LearnAccessByCrystal

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page book that covers essentials in Access

*
:) have an awesome day :)
*
 

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

Similar Threads


Top