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

Help with code - again

Status
Not open for further replies.

kfenner

Technical User
Apr 6, 2003
52
0
0
US
I need some assistance, again.......I want to try to use the following code, found in an article from this site, to cause a button to open a report based on the current open record. Problem is, in order to successfully key this table, I have to key two fields. How do I alter the code:

var
roi ReportOpenInfo ; parameters for the report.
rpt Report ; the report itself
tc tCursor ; used to capture the current record
endVar

tc.attach( keyField )
tc.setRange( KeyField.Value, KeyField.Value );
tc.instantiateView( ":pRIV:ANSWER" )

roi.Name = "MYREPORT"
roi.MasterTable = ":pRIV:ANSWER"

rpt.open( roi )

I could try to use an arbitrary field for the key, in order to just have one keyed field, but I have no clue how to go about this successfully.

Any help is, as always, greatly appreciated.
 
Also:

work:newclient.db|clientname|mattername|
check |~keyval1|~keyval2|

Don't look right to me.

Try:

work:newclient.db |clientname |mattername |
|Check ~keyval1|Check ~keyval2|




Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Woo hoo. Your help, and along with the fact I had a missing colon in my actual code.........has now fixed the issues! Thanks so much! I was about to give up!
 
Hey I was sweating it too - got my reputation to think of (ha ha) ;)



Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Gongratulations,

Now what's this about your missing colon...

:)
 
<SIGH> I got excited too soon. The button works, and creates the report, but, it creates a report for every record, not just the current open record. what's up with that?
 
It sounds like a problem with the query, back up a little, langley said:

work:newclient.db|clientname|mattername|
check |~keyval1|~keyval2|

Don't look right to me.

Try:

work:newclient.db |clientname |mattername |
|Check ~keyval1|Check ~keyval2|


You had it right the first time, the check outside the fields will check all the fields. The way he changed it will result in a query result for two fields. This however does not explain why the query is not giving you the desired result, my guess is that the variables are not being assigned.

you may want to add:

keyVal1=clientname.value
keyVal1.view()
keyval2=mattername.value
keyVal2.view()

to be sure the variables are being assigned.

 
Ok, I tried that. It brings up boxes with the value of the current record, then you have to click &quot;ok&quot;. However, when the report is created, it still has all the records on it, instead of just one record.
 
Hmmm, have you checked the answer table? does it have all the records in it? I'm not so sure this is easier than your original method. You could have used the tcursor.open() method instead of tcursor.attach() but lets not backtrack lets get this working. If the query is running correctly and giving you the one record result that you are looking for then I would suspect that the report is not based on the answer table.
 
Ok, I think I'm following you. Not to backtrack, I did try the other code and replaced &quot;attach&quot; with &quot;open&quot;. It still gave the unknown identifier syntax error.

Now, the report was designed built on the &quot;newclient&quot; table. So, how do I make it based on the answer table, and still make it look like I want it to?
 
You will need to replace the newclient table in the datamodel with the answer table and re-assign the fields.

The tcursor attach/open issue sounds like a syntax most likely in the way you are calling the table.
 
I've found that the fastest way to do that is to rename the client.db table to something like xclient.db. Then open the report based on client.db and you will get an error; it will ask you if you want to replace client.db in the data model. Tell it 'yes' and pick :priv:answer.db.

Make sure you have run the query that session (since opening Paradox) or there will be no (or worse, the wrong) answer table.




Mac :)

&quot;There are only 10 kinds of people in this world... those who understand binary and those who don't&quot;

langley_mckelvy@cd4.co.harris.tx.us
 
Yeah, I guess you could do it that way if you had something else to do and didn't want to spend a bunch of time doing it the way I suggested... :-O
 
Ok, I fixed this problem, and this seem to be working well. There is only one more issue. I'm sure it is a simple fix. I tried one way, and it works, but just want to make sure there isn't a better way to do it.

There is a button on this form to enter a new record. You use that, then fill out the form. When you go to use the report button, to create the report for the record, it does now create a report based on one record, however, it is the previously created record, and not the new one you just filled out. You have to close the form, then reopen it to do this. So, I put a button on the form with the code &quot;action(DataPostRecord)&quot; and this solves the problem, but does create a lock on the record. Is this going to be a problem, or is there an easier or better way to do this?

Thanks again guys for all your help. I would probably have pulled out all my hair by now if not for you.
 
When you create the new record you Paradox puts a lock on that record, you will need to post the new record before running the query. action(dataPostRecord) will not put a lock on the record, it only posts the changes to the table and leaves the locked record locked. Try using action(dataUnlockRecord) or unlockRecord() before running the query. This will post the changes and unlock the record.

Glad your getting it working
Perrin
 
Will it hurt anything or cause any problems to not unlock it before running the query? I'm just learning so much here : )
 
No, the key here is you must post the record for the query to pick up the changes, you don't need to unlock it.
 
Cool, then I actually managed to fix a problem on my own! Yea for me! I feel like I really accomplished something. You all must be teaching me well! : )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top