Avatar billede magerlin Nybegynder
20. december 2004 - 17:03 Der er 5 kommentarer og
1 løsning

Date validation rule. Not more than 1 month bigger than value in

Date validation rule. Not more than 1 month bigger than the value in a query which only contains this date.
A query called q-lastbookeddate contains the last date where depriciations were run (usually the last date of previous month). In a form there is a date field which the user enters. I would like to validate that the user does not enter a date bigger than 1 month ahead of the date in q-lastbookeddate.
TIA
Avatar billede terry Ekspert
20. december 2004 - 18:38 #1
You can try this in the forms BEFORE update

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Me.LastBookedDate > DateAdd("m", 1, DFirst("LastBookedDate", "tblSystem")) Then
    MsgBox "Date wrong"
    Cancel = True
End If

End Sub
Avatar billede magerlin Nybegynder
21. december 2004 - 09:08 #2
q-lastbookeddate is not linked or a part of the private sub form, is that the problem I have in this line (It does not understand Me.LastBookedDate)
If Me.LastBookedDate > DateAdd("m", 1, DFirst("LastBookedDate", "tblSystem")) Then...

Secondly I have the feeling that vba does not "like" -(score, I think it is called), which might be a problem due to the fact that my query and table names all uses eg. t-reg, q-lastbookeddate..?
TIA
Avatar billede terry Ekspert
21. december 2004 - 09:13 #3
Me.LastBookedDate is the name of the field on your form

LastBookedDate in the dlookup function is the name of the field in your table which in this example is tblSystem

You should try and give your tables/fields etc names WITHOUT - and try and keep to english characters a-z 0-9

If you still cant get it working then you are welcome to send your dB to me

eksperten@NOSPAMsanthell.dk
remove NOSPAM
Avatar billede magerlin Nybegynder
21. december 2004 - 10:15 #4
Thanks a LOT! :-) It is so beautiful... Have a nice Christmas and a Happy new year. (I might be back before that, but anyway)
Avatar billede terry Ekspert
21. december 2004 - 10:25 #5
you have a good Xmas an dnew year too
Avatar billede terry Ekspert
21. december 2004 - 10:25 #6
and thanks
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester