Avatar billede jmarques Nybegynder
25. januar 2012 - 02:38 Der er 32 kommentarer og
1 løsning

Inputmaske til dato og klokkeslet

Hej alle,

Jeg har fået hjælp til det her før men kan simpelthen ikke få det til at virke og er startet forfra.

Jeg har en tekstboks hvori der skal indtastes en dato og et klokkeslet. Det må meget gerne se ens ud hver gang og se således ud:

Dato: 01-01-2012 Kl.: 01:01

I tabellen er følgende lavet:

- Feltnavn: Barring udløber
- Datatype: Dato og klokkeslet

Feltegenskaber:

- Format: Standarddatoformat
- Obligatorisk: Nej
- Indekseret: Nej
- IME-Tilstand: Intet kontrolelement
- IME-sætningstilstand: Ingen
- Tekstjustering: Standard
- Vis datovælger: For datoer

Da jeg ikke er den eneste der indtaster data i feltet er det nødvendigt med inputmasken. Alternativer er velkomne, og undskyld udtrykket så længe de er "idiot sikret" !

Jeg er ikke en haj til det her og skal have det skåret ud i pap. Så hvis nogen har tålmodigheden ser jeg frem til hjælpen.

Mvh
Joachim
Avatar billede terry Ekspert
25. januar 2012 - 19:26 #1
you need to alter the input mask to something like this

99-99-0000\ 00:00;0;_
Avatar billede terry Ekspert
25. januar 2012 - 19:26 #2
.
Avatar billede terry Ekspert
25. januar 2012 - 19:29 #3
you may need to alter the format in the table to

dd/mm/yyyy hh:nn
Avatar billede jmarques Nybegynder
01. februar 2012 - 15:57 #4
Thanks the first i working but the second input mask does not:

dd/mm/yyyy hh:nn

When I put in this one it stays "frozen" in the formular.

Question:

Can you make the date and time I put in disappear again and leave the textbox blank when that date and time is reached  ?

Would be greatly appreciated as it will be helpful regarding our client deadlines?

Regards
Joachim
Avatar billede terry Ekspert
01. februar 2012 - 19:07 #5
there is a difference between an input mask and a format.

The input mask defines how you have to enter the value, the format defines how it is displayed.

I can try and answer the next question "Can you make the date and time I put in disappear again ..."
once you have the input mask and format working
Avatar billede jmarques Nybegynder
02. februar 2012 - 11:25 #6
Yes i know - The input mask is working now. Did you have time to look at my last question ?
Avatar billede terry Ekspert
02. februar 2012 - 18:57 #7
"Can you make the date and time I put in disappear again and leave the textbox blank when that date and time is reached  ?"

It all depends on how your using the form/date time field.

You need to give more information so I have some idea of how your database works.
Avatar billede jmarques Nybegynder
02. februar 2012 - 19:39 #8
Ok here goes:

Every day the database is opened and kept open until closing time. Not every form. We have a form called "Kontaktpersoner" for our clients. It is opened by me when different information about our clients are given to me.

I find their "profile" in the form. The text box which you gave me the inpumask for, is a box that are supposed to show a deadline - a date and time.

If there is no deadline = No numbers/date and time in the box - the excell ark I made which my colleagues use will also be blank (in a specific cell).

This will speed up the work process in my department. It would be greatly appreciated if it was somehow possible to make the date and time disappear automaticly in the form (database) that I use so that I dont have to do it manually. We have a lot of clients:-)

Thanks in advance for all your help.
Avatar billede terry Ekspert
02. februar 2012 - 21:06 #9
I assume that the date/time field has to be visible at least until the data and time is reached. So when exactly would it be appropriate to clear the field?

It would be quite easy to update records (Date/time field) at intervals by having a timer event in the form but if the date/Time field is required for some purpose then that wouldnt be a good idea.

So when in the work process could it be cleared?

I'm off to see some TV will look again sometime  tomorrow
Avatar billede jmarques Nybegynder
03. februar 2012 - 14:18 #10
I assume that the date/time field has to be visible at least until the data and time is reached - Yes that is correct.

Well it would be most helpfull if the date/time could be cleared 24 hours after the date/time I put in the field, if possible?
Avatar billede jmarques Nybegynder
03. februar 2012 - 14:19 #11
Nonooo please at the exact date/time in put in please.
Avatar billede terry Ekspert
03. februar 2012 - 16:00 #12
Why dont you take another approach?
Use conditional formatting to show the date/time field in different colours.
For example you could show the field as green if the current date time is more than 24 hours less than the date/time in the field. Then show it as red when the current date time is less than 24 hours less than the date/time in the field.

Then you could also have some code which deletes all date/times < currenty date/time. This could be done in timer event on the form.
Avatar billede terry Ekspert
03. februar 2012 - 16:02 #13
I dont think its a good idea to delete it as soon as it is reached, what happens if some one was supposed to take action but becuae its deleted you can see it any more?
Avatar billede jmarques Nybegynder
03. februar 2012 - 16:45 #14
Its not that kind of deadline - as long as there is a date/time no action are to be made before that.

But if no deadline is there one is free to go ahead.

Maybe time limit is a better word - sorry my english is not better.
Avatar billede terry Ekspert
04. februar 2012 - 09:58 #15
Because the form is open all the time then it might be an idea to use the forms timer event to delete old records.
http://msdn.microsoft.com/en-us/library/bb214858(v=office.12).aspx

Then in code use something like

DoCmd.RunSQL "Update YourTable Set DateTimeField = null Where DateTimeField < Now()"
Avatar billede jmarques Nybegynder
07. februar 2012 - 16:44 #16
Ok I will try it thanks !
Avatar billede jmarques Nybegynder
07. februar 2012 - 16:55 #17
When I open the form after putting in the code in "OnActual" a small box comes up that says:

enter the parameter value
DateTimeField
Avatar billede terry Ekspert
07. februar 2012 - 18:54 #18
DoCmd.RunSQL "Update YourTable Set DateTimeField = null Where DateTimeField < Now()"


YourTable and DateTimeField must be replaced by the table/field names you have, these are just examples.
Avatar billede jmarques Nybegynder
07. februar 2012 - 19:58 #19
That I have done.

It gives me a run-time error 3073 The action needs an updateable request.

I think I am having trouble with Form.Timer Event:

Private Sub Form_Timer()
    Clock.Caption = Time        ' Update time display.
End Sub

I have looked at the link you also gave me.

I have put in a Date and Time but I can not see the time live so to speak. It updates when I open the form.

I am of now I will be back at my desk later this week.

Again thanks for all your help.
Avatar billede terry Ekspert
07. februar 2012 - 20:48 #20
you coul dmaybe send an example dB so I can see what the problem is?

ekspertenATsanthell.dk
AT = @
Avatar billede jmarques Nybegynder
11. februar 2012 - 11:36 #21
Ok I will do that.
Avatar billede jmarques Nybegynder
11. februar 2012 - 11:48 #22
Well that did not go well. I cant send it I apperantly are not allowed to do so.

By both system and Boss i´m  affraid.
Avatar billede terry Ekspert
11. februar 2012 - 12:18 #23
OK, then maybe we can try and find the problem without sending.

Cab you see if the timner event gets fired at the interval you have set it to?

you could use

debug.print "Here ..."
in the timer event
and then in the debug window (CTRL+G)  you can see if "Here ..." is getting printed
Avatar billede terry Ekspert
11. februar 2012 - 12:20 #24
Once we know the timner event is working we can get the SQL working
Avatar billede jmarques Nybegynder
11. februar 2012 - 14:48 #25
I have not put in any interval I am having trouble with that.
Avatar billede jmarques Nybegynder
11. februar 2012 - 14:59 #26
Im not sure what oyu mean with debug.print "Here..."
Avatar billede terry Ekspert
11. februar 2012 - 15:28 #27
have you followed the instructions from the link I gave?http://msdn.microsoft.com/en-us/library/bb214858
Avatar billede jmarques Nybegynder
11. februar 2012 - 16:07 #28
Im trying :-)
Avatar billede jmarques Nybegynder
11. februar 2012 - 16:19 #29
I think I have done as you said now:

In form Kontaktpersoner property "OnActual" I have put in:

Private Sub Form_Current()
DoCmd.RunSQL "Update Kontaktpersoner Set Tekst92 = null Where Clock < Now()"
End Sub

The the box with the inputmask for date/time is called "Tekst92" and The Timer.Event is called "Clock"

I have set the TimerInterval to: 1000

Descriped in your link for Form.Timer Event I have put in:

Private Sub Form_Timer()
    Clock.Caption = Time        ' Update time display.
End Sub
Avatar billede jmarques Nybegynder
11. februar 2012 - 16:23 #30
I am sure I have confused my self completely now !!

The error i get now is:

Run-time error "3073"
Handlingen skal bruge en opdaterbar forespørgsel.
Avatar billede jmarques Nybegynder
11. februar 2012 - 18:19 #31
Aaaaaaaaaaaah I have to start over I think !!
Avatar billede terry Ekspert
12. februar 2012 - 19:01 #32
your confusing me too :o)

There is an event on the form named TimerInterval. Set this to 1000.

There is an event OnTimer, set this to event Procedure so you get the code.

Private Sub Form_Timer()

End Sub

then add

DoCmd.SetWarnings False
DoCmd.RunSQL "Update Kontaktpersoner Set ThisIsTheDateFieldInTheTable= null Where ThisIsTheDateFieldInTheTable< Now()"
DoCmd.SetWarnings False


Replace ThisIsTheDateFieldInTheTable with the correct field in the table.
Avatar billede jmarques Nybegynder
12. februar 2012 - 19:38 #33
Thanks for your patience ! I am close to loosing my mind :-) I will look at it when I am back tuesday I have to leave now. Thanks again.
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