By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 920 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Format combined fields?

P: n/a
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?
Mar 20 '07 #1
Share this Question
Share on Google+
2 Replies


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

Mar 20 '07 #2

P: n/a
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" <do**@email.mewrote in message
news:lp******************@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?

Mar 21 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.