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!

Passing a value to a query

Status
Not open for further replies.

kfenner

Technical User
Apr 6, 2003
52
US
I'm afraid I need some assistance once again. This is what I want to do, but am having trouble getting it to work properly.

I have two tables linked on the "ClientNo" field. This is the key field for the parent table, and one of the key fields in the child table. With a form for the parent table open, I want a button to function as a query, pulling up all records in the child table with "ClientNo" value the same as the current open record in the parent table. I don't want the user to have to input anything, I simply want the button to automatically pass the "ClientNo" value of the open parent table record into the query, then open all the records from the child table with this value in table view, so the user will be able to see all the records from the child table attached to that particular record of the parent table at the same time.

I hope this makes sense, as I am not very good at trying to explain it this way. Thanks for your help.
 
kfenner,

This should be fairly simple to do, first create a variable and assign the current "clientNo" to the variable and use the variable in the query using the "~" run the query then open the answer table in tableview.

the code should go something like this

var
client number
tblView tableview
q query
endvar

client = cleintNoField

q = Query
ANSWER: :pRIV:ANSWER.DB

clientTable.DB | CleintNo |
| Check ~client |
EndQuery

if not q.executeQbe() then
errorshow()
else
tblview.open(":priv:answer")
endif


Hope this helps
Perrin
 
Yes, I do think this helps. Thank you. After seeing your code, I think I may have discovered my problem. I will try this and if I have any other problems, I'll be letting you know. You guys are lifesavers for those of us muddling through this on our own! Thanks!
 
Ok, I have tried what you suggested, but.....when I check the syntax on this, on the line that says "client=clientNoField" (mine actually says client=clientField since the actual field is labeled "Client") it tells me that "clientNoField" is an unknown identifier.........and since I am no expert on this stuff, I don't know where to go from here.
 
kfenner,

You should be asigning the variable to the "Name of object", if the object is named client you will need to use a different name for the variable and make it "= client"

Perrin
 
On your form, I assume you have the current clientField displayed? The "Name of Object" property of that field should be clientField.

Harry
 
I'm going to start again here, because I am still having trouble. Sorry to be such a pain to you all.

Form open is for the client table. A button on this form will open a new form for the the contact table in order to add new contacts. These two tables are linked at the "Client" field level. When the new contact form opens, it automatically passes the value in the "client" field from the first form, to the new form. I need a second button, which will show all records from the "contacts" table with the same value in their "client" field as the record currently open in the "client" table. I want the result to appear in table view.

Here is the code I have, so maybe you can find the problem:

sname client
tblView tableview
q query
endvar

sname=Client.Value
q = Query

ANSWER: :pRIV:ANSWER.DB

Contacts.db |Client |Last Name|First Name |Check~sname | Check | Check |

EndQuery

if not q.executeQbe()then
errorshow()
else
tblview.open(":priv:answer")
endif

endmethod

When I check syntax, it is telling me "client" is an unknown identifier, or it tells me "error: type expected". I'm sure you guys will be able to spot the problem right away, but I'm not that good! : )

Thanks!
 
I still think the problem is with the object name, if you select the client field right mouse click select properties the "name of object" should be client.
 
Ok, I went and made sure the object name said "client" in both forms. Now the errors I am getting is, at the top where it sais "sname client" it highlights "client" and says "type expected", or where it says sname=client.Value it hightlights Value and says "this data type does not support this property"

I realize I sound very ignorant here, but learning this stuff from the ground up alone can be frustrating to say the least.

Once again, thank you for your help and patience with my endless questions.
 
In your var statement you should be assigning sname as a string or number, you are defining it as a client.

sname string
tblView tableview
q query
endvar

Perrin
 
Thank you!! It works! (I had it that way to begin with, should have left it alone) I love you guys so much!! I am learning so much from your help and I appreciate it very much!
 
Yay, glad to help, it's a learning experience for both of us.

Perrin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top