If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Message Box displays on date criteria
Hi All,
I am trying to create some code to make a message box appear on a form, when the 'DestroyDate' field value is less than the 'AddDate' field value plus 365 days. The code I have tried in the Before Update event on the text box is: Private Sub DestroyDate_BeforeUpdate(Cancel As Integer) =IIf([DestroyDate] ([AddDate] + 365),MsgBox("WARNING! Destroy Date is less than one year!"),0) End Sub I get a message saying Compile Error: Syntax Error. Can anyone spot where I have gone wrong? Thanks in advance for your help! -- Message posted via http://www.accessmonster.com |
#2
|
|||
|
|||
Message Box displays on date criteria
To be honest, I have no idea what you were trying to do using IIF()!
But this should do the job: Private Sub DestroyDate_BeforeUpdate(Cancel As Integer) If Me.DestroyDate Me.AddDate + 365 Then MsgBox "WARNING! Destroy Date is less than one year!" Cancel = True End If End Sub -- There's ALWAYS more than one way to skin a cat! Answers/posts based on Access 2000/2003 Message posted via http://www.accessmonster.com |
#3
|
|||
|
|||
Message Box displays on date criteria
Hi Linq,
Thanks very much for the code - it works perfectly. The only slight problem is that it will not now allow me to save the record with a 'DestroyDate' less that one year after the AddDate, as the message keeps re-appearing. Can you think of a way to get round this. Could I set the focus to the next text box (DestroyMethod)? Thanks again, Rob. -- Message posted via http://www.accessmonster.com |
#4
|
|||
|
|||
Message Box displays on date criteria
Just worked out how to do it! Cancel = False.
Rob. -- Message posted via http://www.accessmonster.com |
#5
|
|||
|
|||
Message Box displays on date criteria
quiero mi autentico correo hotmail no este trucho que no pedi
"a1_robs via AccessMonster.com" u49836@uwe escribió en el mensaje de noticias:986e12e564657@uwe... Hi All, I am trying to create some code to make a message box appear on a form, when the 'DestroyDate' field value is less than the 'AddDate' field value plus 365 days. The code I have tried in the Before Update event on the text box is: Private Sub DestroyDate_BeforeUpdate(Cancel As Integer) =IIf([DestroyDate] ([AddDate] + 365),MsgBox("WARNING! Destroy Date is less than one year!"),0) End Sub I get a message saying Compile Error: Syntax Error. Can anyone spot where I have gone wrong? Thanks in advance for your help! -- Message posted via http://www.accessmonster.com |
Thread Tools | |
Display Modes | |
|
|