Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2015
    Posts
    3
    Provided Answers: 1

    Answered: Return Today's Date when Field is called 'Date'

    Hi, I'm quite new to VB.

    Code:
    Private Sub TypeTypeID_Changed()
    
    If Me.TypeTypeID = "4" Then Date = Date
    End
    
    End Sub
    I know that Date returns today's date. I have used this in some simple window customisations where the date field is named something other than 'Date' and it works fine. However in this case, the date field is called 'Date'. There is no change in the date value when TypeTypeID is changed. What I believe is happening is it's picking up the field 'Date' value, and returning what is already in there. The If Statement is working fine as I have hard coded Date = "dd/mm/yy" and it works.

    How do I get it to change to today's date rather than what is the value in the field Date?

    Thankyou

    Tania

  2. Best Answer
    Posted by Tania Mofflin

    "Hi, I have found that you can rename the field value to something else, eg DocDate, and then change the code to -


    Code:
    If Me.TypeTypeID = "4" Then DocDate = Date

    Quote Originally Posted by Tania Mofflin View Post
    Hi, I'm quite new to VB.

    Code:
    Private Sub TypeTypeID_Changed()
    
    If Me.TypeTypeID = "4" Then Date = Date
    End
    
    End Sub
    I know that Date returns today's date. I have used this in some simple window customisations where the date field is named something other than 'Date' and it works fine. However in this case, the date field is called 'Date'. There is no change in the date value when TypeTypeID is changed. What I believe is happening is it's picking up the field 'Date' value, and returning what is already in there. The If Statement is working fine as I have hard coded Date = "dd/mm/yy" and it works.

    How do I get it to change to today's date rather than what is the value in the field Date?

    Thankyou

    Tania
    "


  3. #2
    Join Date
    Oct 2015
    Posts
    3
    Provided Answers: 1
    Hi, I have found that you can rename the field value to something else, eg DocDate, and then change the code to -


    Code:
    If Me.TypeTypeID = "4" Then DocDate = Date

    Quote Originally Posted by Tania Mofflin View Post
    Hi, I'm quite new to VB.

    Code:
    Private Sub TypeTypeID_Changed()
    
    If Me.TypeTypeID = "4" Then Date = Date
    End
    
    End Sub
    I know that Date returns today's date. I have used this in some simple window customisations where the date field is named something other than 'Date' and it works fine. However in this case, the date field is called 'Date'. There is no change in the date value when TypeTypeID is changed. What I believe is happening is it's picking up the field 'Date' value, and returning what is already in there. The If Statement is working fine as I have hard coded Date = "dd/mm/yy" and it works.

    How do I get it to change to today's date rather than what is the value in the field Date?

    Thankyou

    Tania

  4. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Or explicitly tell the compiler that you want to use the date function

    Code:
    ....date = date ()
    However the lesson from this going forward is to be aware of the reserved words and symbols for whatever languages/tools you are using and NOT use any of them
    I'd rather be riding on the Tiger 800 or the Norton

  5. #4
    Join Date
    Oct 2015
    Posts
    3
    Provided Answers: 1
    Thanks but I had already tried that. It removes the brackets automatically after any function. The field was already named Date in the ERP. I only just learned you can rename it in the properties.


    Quote Originally Posted by healdem View Post
    Or explicitly tell the compiler that you want to use the date function

    Code:
    ....date = date ()
    However the lesson from this going forward is to be aware of the reserved words and symbols for whatever languages/tools you are using and NOT use any of them

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •