Results 1 to 5 of 5
  1. #1
    NejcZ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    17

    VBA text posting and conditional formatting

    Hello everyone.
    In my app, I have several Access to Word functions, creating different documents. For that, I'm using bookmarks like this:



    Code:
    .Goto what:=wdGoToBookmark, Name:="wproductNumber"
    .TypeText [productNumber]
    Basically, I want to know, if it's possible to post current date the same way as productNumber mentioned above?
    Also, I was searching all over, but couldn't find it..
    I want to add red background to textbox, which contains let's say more than 5 numbers/characters. Any sample code or suggestion?

    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    I don't know. Can the bookmark accept result of a function?

    .CurrentDate Date()


    You want to add red background to textbox where - in Word?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    NejcZ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    17
    In brackets [] it doesn't work.
    I want to add red background to textfield in Access form.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Brackets are not used with function call. Date() is an intrinsic function.

    Consider textbox Conditional Formatting to manage the back color. Expression like:

    Len([fieldname])>5
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    NejcZ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jun 2014
    Posts
    17
    Thanks, that worked. I was forgetting fieldname in my expressions...
    But for the data, it won't work.

    .Goto what:=wdGoToBookmark, Name:="wdatum"
    .CurrentDate Date()

    If i put that in my code it removes () at the end.


    edit:
    got it solved like that:

    Dim currDate As Date
    currDate = Date()

    .Goto what:=wdGoToBookmark, Name:="wdatum"
    .TypeText [currDate]

    Thanks for your help.

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

Similar Threads

  1. Replies: 7
    Last Post: 08-21-2013, 09:14 AM
  2. Conditional Formatting of a text-box
    By GraeagleBill in forum Forms
    Replies: 9
    Last Post: 04-06-2013, 11:22 PM
  3. Replies: 5
    Last Post: 08-20-2012, 11:11 PM
  4. Conditional Formatting of Text Boxes
    By beribimba in forum Reports
    Replies: 2
    Last Post: 03-09-2012, 05:08 PM
  5. Replies: 0
    Last Post: 11-13-2009, 10:18 AM

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