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

select from table 3

Status
Not open for further replies.

harrymossman

Technical User
Sep 5, 2002
255
US
I have a form with a select-from list on it. The user selects an item on the list then pushes a button. The form runs a query based on the selection.

The value selected in the list (nameList.value) gets passed to the query but the table comes up blank.

I have run the query as a stand-alone query, with a name inserted in place of ~qName. It works fine.

Can anyone tell me what I am doing wrong?

Code:
method pushButton(var eventInfo Event)

var

q query
tv tableview
r report
qName string

endVar

doDefault

qName=nameList.value

q=Query

ANSWER: :PRIV:projects.DB

ASSIGNED.DB | Assigned       | Branch |
            | ~qName, _join1 | Check  |


LOG.DB |  Year  | Number |Assigned     |
       |  Check | Check  |Check _join1 |

EndQuery

if not executeQBE(q) then

errorShow()
msgInfo("Error","Unable to run query")

setMouseShape(mouseWait)

else

setMouseShape(mouseWait)

tv.open("projects.db")

endIf

endMethod
 
Code looks ok, except the answer table is in :pRIV: while the tv is trying to open a table in :WORK: - is that just a typo? Try tv.open (":pRIV:projects.db).
To help debug, insert the following line after qName=nameList.value :
msgInfo("" qName)
 
Also, you might consider writing the query out to a QBE file when it fails. I've used this to help debug code-based QBE queries and it's a tremendous time saver for me.

Example:

Code:
if not executeQBE(q) then

   setMouseShape( mouseArrow )
   errorShow( "Can't run query", "Use [>>] for details." )
   q.writeQBE( ":PRIV:BADQUERY.QBE" )

else
   ; and so on...
endIf

Once the query has been written, simply try to open it from Paradox interactively. If it runs, then you know it's not the query itself. If it doesn't, then you'll usually get more information to work with.

Hope this helps...

-- Lance

 
Thanks OGrifola & Lance,

Excellent tips! I'll paste them in my tips file.

Unfortunately, they didn't help. The right qName gets passed and the query runs. But the table comes up empty.

Harry
 
Really strange...

Is it possible that your list value has a space in front of it?

Maybe try:

qName=".."+nameList.value+".."

instead of:

qName=nameList.value


to find out. Mac :)

"Gurth a choth-en-America! Tôl acharn..."


langley_mckelvy@cd4.co.harris.tx.us
 
I agree, really strange - come on, there's something you're not telling us.
Does nameList.value start with a numeric - this sometimes causes errors in the query - workaround is qName = "\"" + nameList.value + "\"". (However you are not getting an error.)

Are there any privileges set on existing :pRIV:projects.db which are not available when running the code, i.e. has the code has the necessary rights to delete :pRIV:projects.db?

A blind shot, which I don't think has any bearing: you have 2 blank lines before LOG.DB - the query builder usually only places one blank line (worth a try).

Use Lance's q.writeQBE( ":pRIV:BADQUERY.QBE" ) anyway and inspect BADQUERY.QBE in a text editor.
Let's know.

I assume that a match for nameList.value exists in ASSIGNED.DB and LOG.DB

 
One additional thought - should it not be q.executeQBE() - i.e. use the method, not the procedure. The procedure syntax is:
executeQBE ( var db Database, var qVar Query
[ , { const ansTbl String |
var ansTbl Table |
var ansTbl TCursor } ] ) Logical
which looks like it requires 2 parameters (never noticed that before!)
 
OGriofa,

That's only one of the prototypes; there's another that doesn't require the database (it assumes the default one).

Remeber, you can get a list of all the prototypes by setting userLevel to "Undocumented" and then calling enumRTLMethods().

Also, hitting Ctrl+T in the Editor will pop up the Quick Lookup dialog, which also shows all the prototypes for each class.

Hope this helps...

-- Lance
 
Hi Lance.
I agree that, logically, it should assume the default database. The puzzle is that the syntax I gave covers all the documented or undocumented overload executeQBE procedures in V8. I can't see one that requires less than 2 parameters - that was the surprise. But there must be one, or the compiler would generate an error, wouldn't it? - unless the compiler was a bit buggy... I just never noticed before.
Thanks for the tip with CTRL-T. Forgotton about that too... must mean something <g>.
Padraig
 
OK, you guys are starting to lose me now!

Paradox doesn't like the space in Lastname, Firstname. How can I change qName=&quot;..&quot;+nameList.value+&quot;..&quot; to get around this? I did generate and run BADQUERY.QBE at Lance's suggestion. It only works if I put quotation marks around the ..lastname, firstname..

Harry

Code:
method pushButton(var eventInfo Event)

var

	q				query
   tv				tableview
	qName			string

endVar

doDefault

qName=&quot;..&quot;+nameList.value+&quot;..&quot;
msgInfo(&quot;qName&quot;, qName)

q=Query


assigned.DB | Assigned  	  |
            | ~qName, _join1 |


projects.db | Year  | ProjNumber | Assigned     |
            | Check | Check      | Check _join1 |

EndQuery

if not executeQBE(q) then

errorShow()
setMouseShape( mouseArrow )
   errorShow( &quot;Can't run query&quot;, &quot;Use [>>] for details.&quot; )
   q.writeQBE( &quot;:PRIV:BADQUERY.QBE&quot; )


else


tv.open(&quot;answer.db&quot;)

q.writeQBE( &quot;:PRIV:BADQUERY.QBE&quot; )

endIf


endMethod
 
Workaround is same as that given for a string starting with a numeric :
qName = &quot;\&quot;&quot; + nameList.value + &quot;\&quot;&quot;
 
Well that certainly explains what was wrong. I guess we should have asked to see some sample data - lol. Mac :)

&quot;Gurth a choth-en-America! Tôl acharn...&quot;


langley_mckelvy@cd4.co.harris.tx.us
 
>>Well that certainly explains what was wrong. I guess we should have asked to see some sample data - lol.

Well, there was other dumb stuff that you guys helped me catch. But this was the final clue that made it work.

Thanks to all!
Harry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top