Results 1 to 6 of 6
  1. #1
    dada is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    40

    Trim value

    Good day to all! I was just wondering if it is possible to trim a value from the database and make an if statement on it.. for example i have a value in my database that's like 09/10/2010.. what i want to do is just get the value of the first 2 numbers and make an if statement like:

    if ## = ## then
    msgbox "Your month is September"
    else if ## = ## then


    msgbox "Your month is November"
    End If

    i hope i made it clear.. please help..

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    if your field type is Date/Time then you can use:
    here [fldTimeStamp] Data type is Date/Time.
    Format([fldTimeStamp],"mmmm")

    please mark the thread solved if your problem is solved

  3. #3
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Format([Name of your Field here],"mmmm")

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Maximus, please show him/her how if the field is text type. show all the code should be better than only an expression.

    And maybe he/she doesn't need the if...else.

  5. #5
    dada is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    40
    thanks! awesome i have solve my problem now..

  6. #6
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Format([YourDateField],"mmmm") can be used even if your date is a text field but in a proper date format like

    Example:
    Like you date is entered like: 6/5/2010 and the field type is not Date/Time and is Text then also this expression can be use:

    but suppose ur date is entered as a text in this format:
    652010:

    Format(DateSerial(Right([fldTimeStamp],4),Left([fldTimeStamp],1),Mid([fldTimeStamp],2,1)),"mmmm")

    here I have used date Serial and Right, Left, Mid Functions to get the required result.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Trim Function
    By ZMac in forum Reports
    Replies: 9
    Last Post: 08-30-2010, 07:36 AM
  2. Need Help with TRIM command
    By rbfarley in forum Reports
    Replies: 3
    Last Post: 01-08-2010, 02:03 PM
  3. COPY DATA and TRIM
    By Ed H in forum Access
    Replies: 1
    Last Post: 01-01-2009, 07:01 AM
  4. Trim
    By JMantei in forum Forms
    Replies: 1
    Last Post: 06-20-2006, 02:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums