Displaying Date in a txt box after Check Box is selected.

Malkavian

Registered User.
Local time
Today, 15:10
Joined
Jan 26, 2006
Messages
23
I need help in the actionscript for a db im creating.

I need to have today's date display in a txtbox after a checkbox is selected and then have that date recorded in the corresponding field on a table.

Help :(

- Malk
 
Malkavian said:
I need help in the actionscript for a db im creating.

I need to have today's date display in a txtbox after a checkbox is selected and then have that date recorded in the corresponding field on a table.

Help :(

- Malk

You can use the Now() function. If it is a bound form it should fill itself. If it is a unbound form you will need to use a recordset to populate that field.

PS, love the name..does that mean you're a bit crazy?:D
 
selenau837 said:
You can use the Now() function. If it is a bound form it should fill itself. If it is a unbound form you will need to use a recordset to populate that field.

PS, love the name..does that mean you're a bit crazy?:D

Shhh not so loud, my boss might hear! :D Thanks.

And thanks for the quick response!!!! I'll see if I can interpret your answer correctly and sove my problem. I have less than 3 hours. :o

- Malk
 
Ok I haven't a clue.

My vb is very rusty. I figure i would use an IF function? But im not sure how to code it.

If the textbox is "filecomptxt", the Check box "filecompck" and the Table Field for the date is "File Comp Date"

would it look something like this?

-----------------------------------------------
Option Compare Database
Option Explicit

Private Sub filecomptxt_BeforeUpdate(Cancel As Integer)

If filecompck = "yes" Then Now ??? I'm lost....

End Function
-----------------------------------------------

- Malk
 
Malkavian said:
Ok I haven't a clue.

My vb is very rusty. I figure i would use an IF function? But im not sure how to code it.

If the textbox is "filecomptxt", the Check box "filecompck" and the Table Field for the date is "File Comp Date"

would it look something like this?

Code:
-----------------------------------------------
Option Compare Database
Option Explicit

Private Sub filecomptxt_BeforeUpdate(Cancel As Integer)

If filecompck = "yes" Then Now ??? I'm lost....

End Function
-----------------------------------------------

- Malk


Why do you want it before update. You need to put it on the afterupdate or the onchange event of that checkbox.

Code:
IF (checkbox name) = true  (or may be 1, because access sees those as 0 or 1)
then 
(date textbox) = Now(0)
else
end if


Does that makesense?
 
Thanks Selena, that makes sense.

So I put this in as follows:

Private Sub filecompck_Click()

If filecompck = True Then
filecomptxt = Now(0)
Else
End If

End Sub

I get an error back because of the "(0)" at the end of the NOW.
So i remove it and run it again.

This time it works. The date it populated in long version with the time aswell.
Would an inputmask work here?

How do I make it so that it only displays in short date?

And if I uncheck the checkbox, how do I have the date reset? That's my nxt challenge.

- Malk
 
Malkavian said:
Thanks Selena, that makes sense.

So I put this in as follows:

Private Sub filecompck_Click()

If filecompck = True Then
filecomptxt = Now(0)
Else
End If

End Sub

I get an error back because of the "(0)" at the end of the NOW.
So i remove it and run it again.

This time it works. The date it populated in long version with the time aswell.
Would an inputmask work here?

How do I make it so that it only displays in short date?

And if I uncheck the checkbox, how do I have the date reset? That's my nxt challenge.

- Malk

Take the 0 out of the ()

if you don't want now() try Date() I think that displayes the short date. You can also look up the help file for the date stamp funciton. Just hit F1 in Access.

As for toggling it off, I don't understand. You want it to change the date.

I would think by selecting the yes again it would change it.
 
selenau837 said:
Take the 0 out of the ()

if you don't want now() try Date() I think that displayes the short date. You can also look up the help file for the date stamp funciton. Just hit F1 in Access.

As for toggling it off, I don't understand. You want it to change the date.

I would think by selecting the yes again it would change it.

Ack you beat me... hehe i was editing my previous post.


I figured out that "Date" would resolve the long version problem and it did.

But if my checkbox is uncheck, i would like the textbox to display nothing (blank) if possible. Otherwise using the if function i guess i could have it just display "00/00/00" if theres no other option.

- Malk
 
Nvm about the blank part... I figured I'll just stick with "__/__/____" lol...

My next challenge is to now link the checkbox from above with 4 other check boxes.

So if 4 specific boxes are marked, the above box's value will become true and then populate the date in the textbox. :p

- Malk
 
Malkavian said:
Ack you beat me... hehe i was editing my previous post.


I figured out that "Date" would resolve the long version problem and it did.

But if my checkbox is uncheck, i would like the textbox to display nothing (blank) if possible. Otherwise using the if function i guess i could have it just display "00/00/00" if theres no other option.

- Malk


What happnes if they accidently change the yes to no, do you want a validtoin to make sure they want that. try this.

Code:
If filecompck = True Then
filecomptxt = date()
Else
if filecompck = false then
  if filecomptxt is notnull then
  msgbox ("ARe you sure you want to change to no?) (make it a yes no)
        if the msgbox = yes then
        filecomptxt = ""
        else
 else
filecomptxt = ""

end if
end if
end if

It is something like this. Not good at writint it on the fly.

basicly what I have done is

if the yes button was selected and it is changed to no, make sure that is correct. If it was an aciident, leav4e the date as is..if they want to chagne it to know..amke that field blank.


Sorry, in hurry here..hope this makes sense.






End If

End Sub
 
Thanks selena for your help.
I don't want you to hurry on my account.

The 1st checkbox linked to the textbox we've been talking about will only have a true value if 5 other check boxes are marked as true. That would be my fail safe for this feature and could not undone unless they unchecked one of those 5. Which is ok to do. lol

How would you link those 5 boxes to the final one?

- Malk
 
Malkavian said:
Thanks selena for your help.
I don't want you to hurry on my account.

The 1st checkbox linked to the textbox we've been talking about will only have a true value if 5 other check boxes are marked as true. That would be my fail safe for this feature and could not undone unless they unchecked one of those 5. Which is ok to do. lol

How would you link those 5 boxes to the final one?

- Malk


Ohh My...that will take more thought than my li'l hamster has at this moment. Once my get my work done here, I will think about it.

My best advice until then is to say what you want it to do in english. That in a way is psudo code, and will help you then change it to VB.

Do me a favor. Write out in english what you want it to do, including each event and when it will fire, and I'll help you translate it to VBA. OK!!
 
Alright, I've attached the DB in zip format.

:p

Call me toll free 1-800-367-9305 x51850

I'll be in the office till 4pm EST.

If you can fix this for me, I'll send you a check for your troubles.

- Malk
 

Attachments

Malkavian said:
Alright, I've attached the DB in zip format.

:p

Call me toll free 1-800-367-9305 x51850

I'll be in the office till 4pm EST.

If you can fix this for me, I'll send you a check for your troubles.

- Malk

Ummm, no money is necessary!

I just need you to physicially write down what you want it to do and I will help you translate to VBA.
 
If notecompck & mortcompck & asscompck & tpcompck & inscompck = true then
filecompck = true.
else filecompck = false.

if filecompck = true then
filecompdate = date
else filecompdate = __/__/____

- Malk
 
Malkavian said:
If notecompck & mortcompck & asscompck & tpcompck & inscompck = true then
filecompck = true.
else filecompck = false.

if filecompck = true then
filecompdate = date
else filecompdate = __/__/____

- Malk

Try this.

Code:
If notecompck = true and mortcompck = true and asscompck = true and tpcompck = true and inscompck = true Then
	filecompck = true
            	filecompdate = date()
      else 
	filecompck = false
             filecompdate = ""

end IF
 
selenau837 said:
Try this.

Code:
If notecompck = true and mortcompck = true and asscompck = true and tpcompck = true and inscompck = true Then
	filecompck = true
            	filecompdate = date()
      else 
	filecompck = false
             filecompdate = ""

end IF

What sub do I place this under? When under general declarations nothing happens.

- Malk
 
Malkavian said:
What sub do I place this under? When under general declarations nothing happens.

- Malk

Hmmmm...good question.

Actually Make it a function.

Code:
Function TrueFalse ()

If notecompck = true and mortcompck = true and asscompck = true and tpcompck = true and inscompck = true Then
	filecompck = true
            	filecompdate = date()
      else 
	filecompck = false
             filecompdate = ""

end IF


end function

Then call that function on each change even for 5 boxes. That way if they are check and changed out of order, it won't make a difference. It will fine and check it every time once is changed.

to call it
Code:
Call TrueFalse
inside each of those events.
 
Ok I set it up but still whilst checking all 5 boxes, the final box does not check.

I've attached the db so you can see. Change the ext to .ace to decompress.

- Malk
 

Attachments

Malkavian said:
Ok I set it up but still whilst checking all 5 boxes, the final box does not check.

I've attached the db so you can see. Change the ext to .ace to decompress.

- Malk

Ok, I can't right now. CAn I get ack with you tomorrow? IF not, hopefully someone else will come along.
 

Users who are viewing this thread

Back
Top Bottom