Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ok Need help with ObjectPal URGENT!!!

Status
Not open for further replies.

RMG112

Technical User
Jan 14, 2002
17
US
I was sent data and the phone numbers were in two seperate fields, how could I make it so ObjectPal Will run through the fields and put them all in one field if there is a way please Help. thank you..
 
Assume the fields are alphanumeric field type, a field type of 'A'.

The table, T2.db, has 2 fields, F1 and F2.
They have a field type of 'A'.
Assume F1 is area code, and F2 is the phone number
F1 F2
123 456-7890

The answer table would look like this:
Phone
123 456-7890

Save this as Q1.QBE

Query
ANSWER: :pRIV:ANSWER.DB

T2.db | F1 | F2 |
| _a | _b, calc _a + " "+ _b as Phone |

EndQuery


 
If this is a one-time event, you do not need to combined the two fields using object-pal. You can easily accomplish this by creating a query that will combine the two values, F1 (areaCode) and F2 (oldNumber), and insert same into a new field F3 (newNumber).

First, add the third field to your table.

Second, create the query. While in field F1, hit F5 to tell Paradox you are going to create an example element, then type AC. If you did this correctly, "AC" and "NUM" will appear in red. Go to field F2, hit F5 and type NUM, which will again appear in red. Go to field F3, and type the following string exactly as shown below:

not BLANK, changeto "(" + AC + ")" + NUM

Before typing AC and NUM, you must again hit F5 to let Paradox know that that you are making references to the F1 and F2 fields. AC and NUM will appear in red if done correctly. Run the query.

If row 1 contained the following text 123, and F2 contained the following text 456-7890, it will be displayed as (123)456-7890 in field F3 after you run the query.

I would only go the object-pal route if this was going to be an ongoing process. First you must create a button on your form, which you will click on every time you want to run your query. In design mode, right-click on the button, and select the pushbutton event. Sample code appears below:

;*******************************************************
;program which combines F1 (area code) and
;F2 (phone number) and displays in
;F3 (area code and phone number)
;*******************************************************

method pushButton(var eventInfo Event)
var
qVar Query
teleNum String
tv TableView
endVar

; create query string which points to your database
; my query points to the test.db

qVar = Query
ANSWER: :pRIV:ANSWER.DB

test.DB | F1 | F2 | F3 |
| _AC | _NUM | BLANK, changeto "(" + _AC + ")" + _NUM |

EndQuery

qVar.executeQBE() ; execute query
tv.open("test.db") ; view the table

endMethod
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top