Results 1 to 7 of 7
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862

    String formating

    All,
    How can I sort by rs!Status so it shows one time for all that is under it? Then is spits out the next status level with all that is under it?

    How can I split up the [ChangeRequested] control? Put a Chr(9) & Chr(9) & at each line break?

    Also I am trying to formats to be easier to read.

    At the moment the below code does this Example:

    Approved

    CR 59 - Change
    whatever changes
    to
    the changes

    Approved

    CR 60 - Disapprove
    Whatever does changes
    from
    whatever changed

    Set rs = CurrentDb.OpenRecordset("SELECT Status,CRNumbers,[ChangeRequested]FROM qryDayActEmail ORDER BY Status,CRID ASC")
    rs.MoveFirst
    While Not rs.EOF
    strMsg = strMsg & rs!Status & vbCrLf & Chr(9) & "CR " & rs!CRNumbers & " - " & PlainText(rs![ChangeRequested]) & vbCrLf & vbCrLf
    rs.MoveNext
    Wend
    rs.Close


    I am trying to get this:

    Approved

    CR 59 - Change
    whatever changes
    to


    the changes

    CR 60 - Disapprove
    Whatever does changes
    from
    whatever changed

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Something similar to this? The code for 59 and 60 are more clearly defined so the Status is managed more efficiently
    Code:
    Set rs = CurrentDb.OpenRecordset("SELECT Status,CRNumbers,[ChangeRequested] FROM qryDayActEmail ORDER BY Status,CRID ASC")
     rs.MoveFirst
     While Not rs.EOF
    select case rs!Numbers
    case = 59
     strMsg = strMsg & rs!Status & vbCrLf & Chr(9) & "CR  " & rs!CRNumbers & " - " & PlainText(rs![ChangeRequested]) & vbCrLf & vbCrLf
    case = 60
    strMsg = strMsg &  vbCrLf & Chr(9) & "CR  " & rs!CRNumbers & " - " & PlainText(rs![ChangeRequested]) &  vbCrLf & vbCrLf 
    End select
    
     rs.MoveNext
    
     Wend
     rs.Close

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    Andy49,
    I see what you are doing in your suggestion. My fault for not explaining better lies in that rs!CRNumbers is always increasing and doesn't stay at 59 or 60.

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Are they in ascending order? 59,60,61...............................125,126 and so on

  5. #5
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    How about something that tests the status.............


    Code:
    Set rs = CurrentDb.OpenRecordset("SELECT Status,CRNumbers,[ChangeRequested] FROM qryDayActEmail ORDER BY Status,CRID ASC")
     rs.MoveFirst
     While Not rs.EOF
    select case rs!Status
    case = "approved"
     strMsg = strMsg & rs!Status & vbCrLf & Chr(9) & "CR  " & rs!CRNumbers & " - " & PlainText(rs![ChangeRequested]) & vbCrLf & vbCrLf
    case = "disapprove"
    strMsg = strMsg &  vbCrLf & Chr(9) & "CR  " & rs!CRNumbers & " - " & PlainText(rs![ChangeRequested]) &  vbCrLf & vbCrLf 
    End select
    
     rs.MoveNext
    
     Wend
     rs.Close

  6. #6
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    Andy49,
    I see what you are doing in your suggestion. My fault for not explaining better lies in that rs!CRNumbers is always increasing and doesn't stay at 59 or 60.
    Correct, but they can also be .01, .02.....
    29
    .01
    .02
    40
    50
    .01

    And so on.
    The numbers start with
    CRNo & SubNo

    CRNo + Format([SubNo]*0.01,"Fixed"))

    I do have CRID as the Autonumber index, that always increments. But it doesn't mean that the different Status sets will always go from low to high.

  7. #7
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    The easiest way is to lay down the types of rules I abide by.

    CRID is the autonumber index

    I have levels of votes

    [Level]
    Level 1
    Level 2
    Level 3 Cat I
    Level 3 Cat II

    Next I have Status'
    [Status]
    Approve
    Deny
    Defer
    Hold
    Withdraw

    Then I have types of votes
    [Types]
    CMB
    TEWG
    Field

    Then we have the base change number = [CRNo], the sub change number based off from CRNo = [SubNo]

    So each level can have a different Status and is not always in ascending numerical sequence, or even ascending CRID sequence.

    I can sort through a query the status

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

Similar Threads

  1. Formating Numbers
    By Ksinay in forum Access
    Replies: 3
    Last Post: 02-12-2016, 04:26 PM
  2. Formating a texbox
    By alextol in forum Forms
    Replies: 23
    Last Post: 10-01-2013, 11:50 AM
  3. Conditional Formating
    By redbull in forum Reports
    Replies: 2
    Last Post: 03-26-2012, 12:08 PM
  4. Check Box Formating.
    By cap.zadi in forum Reports
    Replies: 1
    Last Post: 11-08-2011, 11:08 AM
  5. Formating string
    By Alex Motilal in forum Reports
    Replies: 7
    Last Post: 12-10-2010, 06:09 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