Buy/sell field in a table

nianko

Registered User.
Local time
Yesterday, 20:50
Joined
Aug 17, 2010
Messages
21
Hi,

Quick/easy question: what is the best type to choose, to create a field in a table (that will feed into a form) that could be "Buy" or "Sell". I would like it to be "buy" by default, because 99% of the time it will be "Buy".

I want then in my form to have a combo box to change from buy to sell if required.

Thanks for your help.
 
You could store you buy transactions and negative values and your sell transactions as positive values. Given that a buy transaction represents a negative cash flow and a sell represents a positive cash flow.
 
Something like -1 for Buy and 0 for Sell in a Number field with a Field Size set to Byte. I wouldn't use -1 and 1 because when looking at the raw data it will be hard to make out Buy or Sell records - just my preference so it's up to you.

Then you need a separate table containing two fields with values that look like this:
Code:
ID    |    TransName
====================
-1           Buy
0            Sell
You can then join this table to your main table via the ID field in the Row Source of your combo box.

OR

You can use the Format property in this fashion:
Code:
;"Buy";"Sell"
where the format for numbers is as follows:
Code:
Positive Numbers[COLOR=Red];[/COLOR] Negative Numbers[COLOR=Red];[/COLOR] the number 0[COLOR=Red];[/COLOR] Null
Or you could use 0 for "Buy" and "1" for Sell. Still up to you.
 
Creating a table to hold an either or value seems to me to be a bit OTT. May be just a s easy to value lists in your combo boxes and IIF() in your queries. In your table have a field to hold the indicator and set the default alue for new records to be that of "Buy", be it a "B" or a "1" or whatever you choose.
 
Yeh, it might be a bit OTT, but I wonder between the IIF() function and an INNER JOIN to the table, which will be more effecient when used in a huge domain.

Another idea is to use a Yes/No data type and a Format property to indicate what Yes and No indicate.
 

Users who are viewing this thread

Back
Top Bottom