Format combined fields?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jimmy

    #1

    Format combined fields?

    Here's my issue. I'm using a calculated control to combine two fields on a
    form & report. The two fields are RecordID (the autonumber primary key) and
    a field named ProductCost. The idea is to create a "mysterious number" on
    the forms & reports to hide the product cost so that customer looking at the
    report wont know what it is. The catch, however, is that the salespeople
    need to be able to quickly decipher the code. Ideally this would mean the
    code would always begin with RecordID as a 4 digit number, the control would
    add leading zeros to make the number 4 digits. It would then consist of the
    price as a 6 digit number... 0000.00, again with leading zeros and always
    two decimals. If possible, it would be even better if I could get the price
    as a 6 digit number without a decimal but I realize that may be asking too
    much. Any thoughts?


  • storrboy

    #2
    Re: Format combined fields?

    Have you looked at the Format() function and thought of how to include
    that in your results?

    Comment

    • Phil Stanton

      #3
      Re: Format combined fields?

      Aircode

      Function CodeIt(RecordID as String, Price as Currency) As String

      Dim StgRecordID as String, StgPrice as String
      Dim PennyPrice as Long

      StgRecordID = CStr(RecordID) ' Convert it to a string
      RIDLoop:
      If Len(StgRecordID ) < 4 Then
      StgRecordID = "0" & StgRecordID
      Goto RIDLoop
      End If

      PennyPrice = CLng(Price * 100) ' * 100 to get rid of
      decimals
      StgPrice = CStr(PennyPrice )
      PriceLoop:
      ...
      ...
      work this out for yourself
      End If
      CodeIt = StgRecordID & StgPrice ' Join the bits together
      End Function

      HTH

      Phil

      "Jimmy" <dont@email.mew rote in message
      news:lpWLh.1060 38$Fq2.517@fe10 .news.easynews. com...
      Here's my issue. I'm using a calculated control to combine two fields on a
      form & report. The two fields are RecordID (the autonumber primary key)
      and a field named ProductCost. The idea is to create a "mysterious number"
      on the forms & reports to hide the product cost so that customer looking
      at the report wont know what it is. The catch, however, is that the
      salespeople need to be able to quickly decipher the code. Ideally this
      would mean the code would always begin with RecordID as a 4 digit number,
      the control would add leading zeros to make the number 4 digits. It would
      then consist of the price as a 6 digit number... 0000.00, again with
      leading zeros and always two decimals. If possible, it would be even
      better if I could get the price as a 6 digit number without a decimal but
      I realize that may be asking too much. Any thoughts?
      >

      Comment

      Working...