473,657 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Take data from a number of fields & make it format a certain way in another field.

Fspinelli
85 New Member
Me again!

I am not sure how to phrase this, "but", I have to create a field that produces data in a specific format from other fields of data.

Creating the table and the query was the easy part...now taking the data that reside in that table, adding in a new field that takes the info from the other fields and makes it look a special way in that new field.

I'm not sure where to put the code in the query. If it's [this security] then the layout in that new field is [their format].

I have a data entry screen that asks for:
Strike (the number)
ExpM (expiration month)
ExpD ("day)
ExpY ("year) (I did them this way because of the format requirements below.)
Month (drop down, chose a three character month, saves to table)
Underlying (same thing which is the SPX I'm talking about)
Call/Put with is a drop down, choose C or P
Security drop down with choices

A silly example:
Security A likes their symbol to look like:
SPX 101017C00975000
(three spaces after the SPX)
SPX YYMMDD(C or P) some zero padding, the number, more zero padding

Here's another exmaple:
Security B likes their symbol to look like:
SPX 10/10/09C975
(one space after the SPX)
SPX MM/DD/YY(C, number and no padding)

And then finally another:
Security C likes their symbol to look like:
SPXOCT975C2010
SPX(three chara month),number,C ,full year. No spaces for anyone here.

Now my screen has fields for data entry and a few have a drop down (list value) combo box. Whatever they choose is written to the main table. Anyway, upon clicking "Enter" button I would like it to enter and save the record into the main table but also pull the info entered in the other fields into the new field that requires it to show in its special format.

I'm sure I'm confusing the heck out of everyone so I'm ready for the questions to begin!
Sep 22 '10 #1
12 1975
Mariostg
332 Contributor
If you have dozens of security, each with their own format, you are up for a good challenge... :)
I make the assumption that they are all saved in the same format but displayed and reported into their own flavor...
That sounds like a VBA approach maybe using a Select Case statement. There is probably a requirement to have a table containing the security with its own format that can be used as a template.
Sep 22 '10 #2
OldBirdman
675 Contributor
No solution here, but a some comments:

1) This can be done with a Select Case but if a new Security is added, or one decides to change something, it will require programmer / database designer intervention at some time in the future. This program will never be finished.
2) Templates - Have each Security define their method and write VBA routine to handle. Access (Microsoft) does this with date formatting where 'yy' means 2 digit year, and 'yyyy' means 4 digit year.
This does not require a programmer in the future, UNLESS somebody wants some feature not in the patterns.
3) All of this means using dates in non-date format, making programming more difficult, and therefore more likely to have errors (bugs).
4) Entering month twice, once as ExpM and again as Month will generate errors when they don't agree. The 3 character name should be derived from ExpM.
5) ExpM, ExpD, and ExpY should be derived from a standard date format. Otherwise, dates such as 2/29/2010 or 9/31/11 will be entered and accepted
6) Without a standard date, sorting and testing of the dates becomes very cumbersome.

I would tell the Boss to form a committee and work out a single method that will be acceptable to all. Otherwise he is bypassing Access' logic and effectively requesting custom programming. Such programming becomes expensive over time.
Sep 22 '10 #3
Fspinelli
85 New Member
Thank you Mariostg and OldBirdMan!

I see. what I will do is get rid of that three charachter month. As long I can take the month from the expiraton date (format that date as mm/dd/yyyy)and make it output a three charachter month for one of the securities output flavor (format requirements) then I should be ok. So I will now have to learn how to write that out in VB.

We use the same handful of securities. It is rare that we would add any, but if we had to I want to be able to make it so and as simply as possible.

Would I then create a table for each security as a template so that when one is used it (for lack of better words) tallies up the securities format in a cell in the row that has the other data (the cells where the data is entered and are the ingrediants for the final cells output?

I hope I'm phrasing this technically close!
Sep 23 '10 #4
Mariostg
332 Contributor
As OldBirdMan said, try to minimize the number of format you have to use. Consistency is important.
Now that whatever string format you try to get, I am not sure if you want to store its end result in a table. i.e. record SPX 101017C00975000 in a field. If so, I don't think it is really advantageous because you would only duplicate information in a different field that exists somewhere. So just create that string when you report or query.

If you have lots of security patterns, you probably want to store them in a table, otherewise I would probably hard code them maybe in an array. But whatever mean you choose, Select Case will likely be involved. Hard coding is prabably easier to get you started.
Sep 23 '10 #5
Fspinelli
85 New Member
Concatenate! That's the word I was searching for in an effort to explain.

Thank you for the information everyone! I am learing so much from here.

Now I just have to figure out how I can take my formulas in Excel and make them work in Access (or at least figure out how to translate it.)

Here's something; what if I have my expiration date in a format without the forward slash ( / ) in it? It's easy to add them to code, but find it hard to remove if a format does not want the slash. Anyway, I have the date like this: mmddyyyy. No slashes.

What if I have a format that takes ddmm (something in between like C or P) and then yyyy? How do I make it so Access knows to take certain characters and arrange them a certain way?

I'm trying to concatenate it but I'm not getting anywhere with it.
Sep 24 '10 #6
Mariostg
332 Contributor
To remove your slashes, or any character, use Replace function:
Expand|Select|Wrap|Line Numbers
  1. stripDate = replace("2010/06/02","/","")
This will replace the / with nothing.

Abuot the C and P thingnie, can you be a little more explicit. Better exemple maybe. You know, it is Friday...
Sep 24 '10 #7
Fspinelli
85 New Member
Thankfully it is Friday.

Ok, I know how to concatenate simple things like first and last names, stuff like that, but this is a doozy.

I have 5 fields in a table.

[Security] - it's a combobox with list values of names of securities. There's about 6 of them.

[Underlying] - a combobox with list values, currently only has "SPX" in it, but eventually we may want to add another.

[PutCall] That's the P & C Thingy. I have a combobox with list values: P;C. The end user would pick one from the drop down box.

[Strike] It's a field in a long integer number format that is used to enter a quantity (like we bought 775 options of something).

[Expiration] That's the slash thing - but thanks for the information! Learned something else new today!

I have to take the information entered into each field of this table and make it produce a Symbol in another field of one table. And the field[Security] is the key.

Each [Security] has a way they arrange their data into a symbol.

For instance
Security A arranges the data like this:
SPX 8/09 C775

[Underlying] A combobox where the SPX came from
<space>
[Expiration] mmddyy is what I currently have but Security A only needs d/yy (that's where the 8/09 comes from).
<space>
[PutCall] combo box allowing user to choose if it's P (for Put) or C (for call)
[Strike] That's the quantity (number), using 775 for this examples

I have a data entry screen where the 5 fields are and the user enters the information. With a push of a button they want it so that the format the Security chosen should be in pops up.

Here are a few examples a few securities and their desired format:

SPX 08/09 C775

SPX US 08/22/09 C775

SPX 090822C00775000
yep...OMG! yy first, month, day, and then the C thingy and zeros for padding!)

SPXAUG775C2009
(yep! another OMG! Month is spelled out in 3 characters,and a full year at the end.)

I've received some very good advise but was hoping someone might have another suggestion to try.

Trying to concatenate the five fields and have it populate into one field named "Symbol" (in same table or another table, whatever is proper).
Sep 24 '10 #8
OldBirdman
675 Contributor
I would create a function to build the string. Function arguments would be all variables mentioned in above posts that are necessary for this. I'm not sure whether "SPX" is a constant (probably not).
I have started a function to demonstrate what I have in mind. It DOES NOT have all the information needed, nor is it complete even for the information provided above. It is meant to be a template.
I tried it in immediate window with these results:
Expand|Select|Wrap|Line Numbers
  1. ?buildsymbol("A",123,12,7,30,"C")
  2. SPX   120730C00123000
  3.  
Here is the code:
Expand|Select|Wrap|Line Numbers
  1. ublic Function BuildSymbol( _
  2.     strSecurity As String, _
  3.     lngStrike As Long, _
  4.     intExpY As Integer, _
  5.     intExpM As Integer, _
  6.     intExpD As Integer, _
  7.     strCP As String) _
  8.     As String
  9.  
  10.  Dim strResult As String
  11.  
  12.     Select Case strSecurity
  13.     Case "A"
  14.         strResult = "SPX   "
  15.         strResult = strResult & Format(intExpY, "00")
  16.         strResult = strResult & Format(intExpM, "00")
  17.         strResult = strResult & Format(intExpD, "00")
  18.         strResult = strResult & strCP
  19.         strResult = strResult & Left("00" & lngStrike & "000000", 8)
  20.         '....
  21.     Case "B"
  22.         strResult = "SPX "
  23.         strResult = strResult & Format(intExpM, "00")
  24.         strResult = strResult & "/" & Format(intExpD, "00")
  25.         '....
  26.     Case "C"
  27.         '....
  28.     Case Else
  29.         MsgBox "New security department - Contact programmer for help"
  30.         Exit Function
  31.     End Select
  32.  
  33.     BuildSymbol = strResult
  34. End Function
  35.  
Once I had this working, I would replace all these date parts with 1 date field. The function could find the month, day, and year using Access built-in funcions such as
Expand|Select|Wrap|Line Numbers
  1. intMonth = DatePart("m", dteExpDate)
  2.  
where dteExpDate is passed to the function instead of intExpY, intExpD, and intExpM.
Sep 24 '10 #9
Fspinelli
85 New Member
Yes, you are all right - I'm making a mountain out of a mole hill. After everyone's advise and further reading I think I know how to explain what I have to do - here it is in detail.


Objective is to make a "symbol" out of the information entered into a data table.

I have three tables:

# 1) Data Table (where the information is entered and stored)

# 2) Expiration Date Table (where the expiration dates reside and are used as a combobox in the Data Table)

# 3) Symbol Table (where the information from the data table gets arranged into a special format to create a special symbol, and stored.)

From all that a report is generated.

In the data table (# 1) I have the following fields:

[Strike] which is a quantity
[Underlyer] combobox with "SPX" as the default
[PutCall] combobox with a "C" and a "P"..."C" is default.
[Expiration] a combobox with a list of expiration dates. The combobox is made from the Expiration Date Table (#2). Whatever the end user choses needs to resides in the [Expiration] field

From those fields I need to create a symbol. There are several symbol format requirements. I don't know how to create a query that takes the info from the data table and lay it out in the several types of symbol formats. Let's say for giggles we need to buy a quantity of 775 shares of something. <space> means I need a space in between characters.

In my symbol table each type needs to spit out a format.

Type 1: The format has to be:
[Underlyer] <space> M/YY <space> [PutCall][Strike]

symbol Example: SPX 8/09 C775

Type 2: The format has to be
[Underlyer]<space> MM/DD/YY <space> [PutCall] [Strike}

symbol example: SPX 08/14/09 C775

To add to the head banging I need:
Type 3 [Underlyer] <space> yymmdd [PutCall] <here I have to put a couple of zeros>[Strike]<some more zeros>

symbol example: SPX 090822C00775000

More head banging:
Type 4 I have to make the format:
symbol example: SPXAUG775C2009

So I am baffled at the type of query I have to write to get the symbols to spit out in the various types of formats. How to pick the first three letters of the month, or only use one character of the month, or add those zeros.

Is there hope for me?
Sep 28 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
9627
by: WindAndWaves | last post by:
Hi Gurus In my quest in putting my first javascript together, I am now trying to conquer something that seems trivial, but has taken me hours. I would like to format a field in a form once the person has completed it. The format should be "00". For example, if the person puts 1 then it should become 01 and if the person puts 12 in the field then it should stay like that. If the person puts 2004 then it should become 04, and if the...
2
6227
by: Jim Craig | last post by:
When I do a transform with a stylesheet containing the function format-number($varname,'#,##0.00') from XSLerator (which uses MSXML) I get the result I expect, a decimal number rounded to 2 places. When I load the stylesheet & do the transform from my VB.NET or C# code however (i.e. using system.xml etc) I always get NaN returned. I don't know why, it took me ages to work it out but the fix is to cast the first parameter in the...
3
4815
by: Harry J. | last post by:
Hello All; We are trying to build a table for tracking times on the Physical Fitness test. Part of the test is the time it takes to swim so many laps or to run a mile distance. Access has time formats where it is HH:MM:SS already defined; however, we only need to keep the MM:SS. Is there a way to format a field to only the minutes and seconds parts? This would make it easier to input, track averages, etc.
10
2835
by: qazmlp | last post by:
I have to store the value of a 'long long' number in Hex format into a buffer. What is the correct & best way of doing it so? E.g.: If the number is: 374643194001883136, the stored value should be 0x0533000000000000 What I have currently is something like this: long long Id = 374643194001883136LL ;
0
968
by: mclagett | last post by:
I am being driven absolutely mad. As part of a generic data access library that was originally written on top of Oracle's OCI and Pro-C libraries but that I am now porting to ADO.NET I am trying to write some generic code to process a DataReader. I am using the GetValues() call to return an array of Object^ refs that I am then trying to process with a bunch of templated code. I originally attempted to read back some Oracle Number fields...
2
6998
by: savigliano | last post by:
hello, i am doing a date comparation and i have reallize that the data i have in my database (general date format) it is causing me problems, and because i don´t need the time data i would like to convert all the general date data into short date format, so i would like to delete the time part of the data, it is any way i can do that ???? Thank you in advance and sorry for my english carlos
1
2742
by: Simon | last post by:
Dear reader, Is there a function or VBA code available to find the week number out of a date field. You can find the year with Year(date field) but now I need the week number out of a date field.
10
10600
by: H | last post by:
Hi, I have the following address fields in a table: flat_number house_name_or_number street village postal_town county postcode
5
3007
by: Dan Tallent | last post by:
I have a scenerio when my forms are first opened that the user cannot modify the data. The fields are disabled to prevent them from modifying any of the data. If a user wishes to modify the data he would be required to click a "Edit" button which will test permissions or status information of the record. If the application determines it is ok for the user to modify the data, it enables the fields where the user now can make changes as...
7
1753
by: Bsorensen | last post by:
I have created a table: TblDVAssociate with 2 fields: Field 1 Name Field 2 Pin <--This is also the Primay Key as I do not want duplicate Pin Numbers I have another table: TblMaster with 6 fields: Field 1 ID (Auto Number)<-- This is the Primary key Field 2 AssociateName Field 3 ProjectName Field 4 Totals Field 5 TimeStart
0
8421
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6177
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.