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!

Querying by value in form field.

Status
Not open for further replies.

caosity

Technical User
Sep 10, 2009
13
US
I know there has to be a way to do this, but I just can't seem to find it. Is there a way to form a query using the data displayed in a field in a form as the criteria? In Access I would just use Form![fieldname, or something to that affect.
 
If you find the answer, I would like it too. A way was indicated to me by someone in the DB Community a while back, but it was far above my skill level at that time.

I found another way on line, which involves entering code for every field, and I bookmarked it somewhere. If I can find it, I will share. I have attempted to do it in a quick and dirty fashion, by attaching the form to the qbe instead of db, but it doesn't work.
 
I have tried the same thing. No luck. I assume it will take a bit of SQL, which is fine, just need to figure it out, or find someone who knows how to do it.
 
You can easily use a variable in a query using the ~ followed by the variable name such as ~fieldVariable. To use the value of a field set a variable to the fields value then use the variable in the query. You can't use the field's value directly in a query.

I haven't used Paradox in a while so if this doesn't make sense let me know and I'll post an example.
 
My apologies, but I think I may need that example. Where do I set the field variable? How do I use the variable in a query where the variable equals the value in the field as displayed on a form?

Also, while I have someone who knows how to do this, say instead of a query, I would like to open another form, or report, where the form or report displays information in other tables regarding the individual, or case number, displayed in a form field. Let me explain. I have several tables established. One of them, say General.db, holds general information regarding a case. We keep track of all our cases by a case number. Another table, say Motions.db, holds information regarding motions for each case. A new record row is created with each new motion, but the case number repeats. Both tables use composite keys which includes the case number.

I have a form set up to display the general information of a case, including the case number. I want a button to push to open the motions form, which I can do. But I want it to open to the motions in the case number displayed in the general information form, which I can't do.
 
Maybe this example will be usefull to you!

It's a partial query I use in an app. to build a answer table for a view!
testOE is a variable used as "variable" column name.
All names with ~ in front are variables.
All names with _ in front are table "connectors".

Code:
testOE = "S"+chrOEM(155)+"genavn"

qbe = Query

	Firma.db	| Kontonr    | ~testOE     | Navn       | Adresse1   | Adresse2  | Postnr |
				| Check _Kto | Check ~SNam | Check ~Nam | Check ~Adr | Check     | _Pst   |

	Kontakt.db  | Kontonr | Lbnr  | Kontakt     | Telefon    |
				| _Kto    | Check | Check ~Att  | Check ~Tlf |

	Postnr.db   | Postnr     | By        |
				| Check _Pst | Check ~By |

	Repair.db   |Kontonr|Garanti  |Hardware  |Fejltype  |Status    |
				|_Kto   |Check ~xG|Check ~Hdw|Check ~Ser|Check ~Sts|

endQuery

Hope this will help you!
I'm not here that often but I still develop in Pdox9 :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top