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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tbrowse Question

Status
Not open for further replies.

SM777

Technical User
Mar 7, 2001
208
GB
Two databases Oldnames and Newnames.

I have a table with two columns. What I want to do is to scroll down the list and if I press F1 I want the data in column 1 to be copied to column 2. i.e. the name in Oldnames to be Newnames

....
oColumn := TBColumnNew("Old Name", FieldWBlock("NAME", 2)
OBrowse:AddColumn(oColumn)oColumn := TBColumnNew("Old Name", FieldWBlock("NAME", 1)
OBrowse:AddColumn(oColumn)

Do while lCont
do while .not. OBrowse:stable .and. (nKey := InKey()) == 0
oBrowse:Stabilize()
enddo

..... etc.

Now the bit where you check for keypresses:

Case nKey == K_F1

What do I put here?

I've tried Newnames->NAME := Oldnames->NAME but that doesn't work.

What should happen is that the corresponding record in Newnames should be replaced with the corresponding record in Oldnames, and the display should update to show both columns with the same (oldname).


 
Can you just clear something up first - are you using two tables or one?

Either way, you be better of with a 'replace xxx with yyy'

so that would generally take the form

Code:
Case nkey == K_F1
  Replace MyTable->Name with MyTable->OldName

Regards

Griff
Keep [Smile]ing
 
and

How are you synchronized-skipping through both tables?
- Set Relation ?
- A special DbSkip codeblock on the TBrowse ?

Normally the skip wil (only!) be performed on the currect area ;-)

HTH
TonHu
 
Yes it's two tables Oldnames and Newnames. There is a relation linking the two.

I have tried the straight replace oldnames->name with newnames->names

It does update the database, but does not update the 2nd column on the screen. In other words the screen is not refreshing with the new data.
 
Hi sm777

You need to trigger a refresh on the tbrowse grid - otherwise it doesn't know the data has changed, there are a number of ways to do this, generally I would use a ReFreshCurrent() or ReFreshAll()

This means your keyboard handler needs a reference to the tbrowse object to work though!

Code:
Case nkey == K_F1
  Replace MyTable->Name with MyTable->OldName
  oBrowse:ReFreshCurrent()

This assumes oBrowse is in scope.


HTH

Regards

Griff
Keep [Smile]ing
 
Sorry,

Should have read

Code:
Case nkey == K_F1
  Replace OldNames->Name with NewNames->Name
  oBrowse:ReFreshCurrent()


Regards

Griff
Keep [Smile]ing
 
That's the ticket. Worked a treat.

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top