> Here we go again....
> Kasey, I've tried changing the field names which created a mess....and
> have
> given up on the query idea of linking these 7 tables to the master and
> getting all of it in a "clientrecord" report. I need to do this
> somehow,
> but no matter what I try, I might get the master table information,
> and none
> of the tied tables show any data at all.
> This is what I'm trying now:
> method pushButton(var eventInfo Event)
> var
> clientTC, oneclientTC TCursor
> rpt Report
> endvar
> ;open tcursors for each table
> if not clientTC.open("unified.db") then
> errorShow("Could not open table Unified.db")
> return
> endif
> ;if in a network environment use the folloiwng line:
> if not oneclientTC.open(":work:holdall.db") then
> errorShow("Could not open table holdall.db")
> return
> endif
> ;locate the current client number in the unified table
> if not clientTC.locate("ID#",ID#) then
> errorShow("Unable to locate client")
> return
> endif
> ;put holdall into edit mode
> if not oneclientTC.edit() then
> errorShow("Could not open holdall table for editing")
> return
> endif
> ;empty the holdall table
> if not oneclientTC.empty() then
> errorShow ("unable to empty table")
> return
> endif
> ;prepare to insert the current record into this table
> if not oneclientTC.insertRecord() then
> Errorshow("could not insert record")
> return
> endif
> ;copy current record from unified.db
> if not oneclientTC.copyRecord(clientTC) then
> errorShow("Unable to copy record")
> return
> endif
> ;take table out of edit mode
> if not oneclientTC.endedit() then
> errorshow("could not end edit")
> return
> endif
> ;close the table
> if not oneclientTC.close() then
> errorshow ("could not close table")
> return
> endif
> ;open report
> if not rpt.open("clientrecord1.rsl") then
> errorShow("Could not open report")
> return
> endif
> endMethod
> This gets as far as the point where it says to me "cannot copy record,
> insufficient field rights, ID#" and this makes no sense to me as the
> table
> holdall does contain the info from the master record. If I then try
> to run
> the report manually none of the tables are tied and none of the
> additional
> data links. I created an additional field in all of the linking
> tables
> especially to link to the holdall table, and the data model has the
> right
> linking information, but it doesn't work anyway.
> When I go through my database, and want to view the totality of info
> on any
> given client, I cannot do it and print it. ARRGH!
> What am I doing wrong here?
> I only get to try this stuff in spare time...blasted it, and there
> isn't
> enough of that.
> There was a point when I had a report that would link EVERY client
> with all
> of their extra tables, but it won't work for just one from a
> pushbutton.
Your code is not very correct : you forget to post the record.
And qLocate does no error : it's simply find or not...
And also empty as no need to have the TCursor in edit mode to work...
I wonder if you are true to place the OneClient table in the WORK alias.
If the only thing to do is to print the report, I am sure you will place
it better in PRIV alias, because, if another user that will push the
same button, the code will try to overwrite the record that is viewing
by the one in first...
I prefer this way of coding
------------------------------------
method pushButton(var eventInfo Event)
var
clientTC, oneclientTC TCursor
rpt Report
id longint
endvar
if ID#.isBlank()
then
return
endif
id = longint(ID#.value)
; it suppose that ID# field is a I table type
errorTrapOnWarnings(True)
TRY
clientTC.open("unified")
oneclientTC.open(":work:holdall")
clientTC.locate("ID#",id)
oneclientTC.empty()
oneclientTC.edit()
oneclientTC.insertRecord()
oneclientTC.copyRecord(clientTC)
oneclientTC.postRecord()
oneclientTC.endedit()
ONFAIL
errorShow()
errorTrapOnWarnings(False)
return
ENDTRY
errorTrapOnWarnings(False)
oneclientTC.close()
if not rpt.open("clientrecord1.rsl")
then
errorShow()
return
endif
endMethod
---------------------------------
This is a concise and sure code.
But if you want to know what is happening in the data transfer from one
record of the TC to the other, instead of the copyRecord metho, do this
:
------------------------------------
method pushButton(var eventInfo Event)
var
clientTC, oneclientTC TCursor
rpt Report
id longint
i smallint
endvar
if ID#.isBlank()
then
return
endif
id = longint(ID#.value)
; it suppose that ID# field is a I table type
errorTrapOnWarnings(True)
TRY
clientTC.open("unified")
oneclientTC.open(":work:holdall")
clientTC.locate("ID#",id)
oneclientTC.empty()
oneclientTC.edit()
oneclientTC.insertRecord()
;############ NEW CODE #########################"
for i from 1 to clientTC.nFields()
oneClientTC.setFieldValue(i,clientTC.(i))
endFor
;############ END NEW CODE #########################"
oneclientTC.postRecord()
oneclientTC.endedit()
ONFAIL
errorShow()
errorTrapOnWarnings(False)
return
ENDTRY
errorTrapOnWarnings(False)
oneclientTC.close()
if not rpt.open("clientrecord1.rsl")
then
errorShow()
return
endif
endMethod
---------------------------------
If this does'nt work, try this
get the value in a anytype type variable with the getValue method from
the table source
WARNING : if you have BLOBS (MEMO, BYTES, GRAPHIC...) you must treat
them with the adequat data type.
BUT : I dont think you have any interest to have the complete record
from table client in the
oneClient table. In fact only the key is necessary : so you can link the
oneClient the the client by the key and the code will be more efficient
and contains less possibility of bugs.
In that case, to modify the report, open it with the option 'change
table', take the client table and save it.
Modify your code, execute it for the first time, then re open your
report and add to the relation ship model the table OneClient in link
with the table client
THE BEST WAY if the only purpose of your code is to print a report is
this :
----------------------------------------
method pushButton(var eventInfo Event)
var
rpt Report
id longint
endvar
if ID#.isBlank()
then
return
endif
id = longint(ID#.value)
RQ =
query
unified.db | ID# |
| Check ~id |
endQuery
if not RQ.executeQBE(":PRIVE:ONECLIENT.DB")
then
errorShow()
return
endif
if not rpt.open("clientrecord1.rsl")
then
errorShow()
return
endif
endMethod