Results 1 to 3 of 3
  1. #1
    kpaull is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    2

    Check value of three text box controls on a form then build text string with results assign to txtbx

    A very junior programmer here. Needing some help to get the desired results with my code:



    What I need my code to do:

    1) I want VBA code to examine the value of three textbox controls:
    txtbox_RT , txtbox_OT, txtbox_DT "Regular Time, Over Time, and Double Time"

    2) Then based on each the values being numeric and > 0, append to a string.

    e.g. #2- Lets say for example, txtbox_RT = 10, txtbox_OT = 3, and txtbox_DT = 0
    The string should only show "RT = 10 OT =3"

    3) Set the string the above string as the value in txtbox_TotalTime.


    My Code:


    If IsNull Me.txtbox_DT Then
    Me.txtbox_TotalTime = "DT:" & Me.[txtbox_DT]

    If IsNull Me.txtbox_OT Then
    Me.txtbox_TotalTime = "OT:" & Me.[txtbox_OT]

    If IsNull Me.txtbox_RT Then
    Me.txtbox_TotalTime = "RT:" & Me.[txtbox_RT]

    Else

    Me.txtbox_TotalTime = "RT:" & Me.[txtbox_RT] & "OT:" & Me.[txtbox_OT] & "DT:" & Me.[txtbox_DT"RT:" & Me.[txtbox_OT]

    End IF



    What you already know my code does:

    My code sets Me.txtbox_TotalTimer to "RT:10 OT:3"

    If there is value of 1 in Me.txtbox_DT (other values in my txtboxes remain as "txtbox_RT = 10, txtbox_OT = 3") my code sets Me.txtbox)_TotalTimer to "" meaning nothing/ blank.

    Any guidance would be appreciated.

    Thank you in advance!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,920
    Saving calculated data (data dependent on other data) is usually not a good idea. Calculate when needed.

    I see no justification for saving in this case.

    Try this expression in textbox:

    ("RT = " + Me.txtbox_RT + " ") & ("OT = " + Me.txtbox_OT + " ") & ("DT = " + Me.txtbox_DT)
    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
    kpaull is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jan 2016
    Posts
    2
    Quite the lesson, thank you it worked! I hope some day to not look for the hardest solution yet the easiest!

    Thanks once again!

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

Similar Threads

  1. Replies: 6
    Last Post: 12-07-2015, 02:09 PM
  2. Replies: 6
    Last Post: 05-29-2015, 10:21 AM
  3. Replies: 3
    Last Post: 12-22-2012, 05:33 PM
  4. Replies: 3
    Last Post: 04-23-2012, 12:06 AM
  5. Check text box string format
    By udik in forum Access
    Replies: 3
    Last Post: 01-04-2012, 01:24 PM

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
  •  
Other Forums: Microsoft Office Forums