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!

Copy Button on a form

Status
Not open for further replies.

dead7

Programmer
Jun 8, 2004
79
0
0
US
I need a copy button [COPYBttn] on a form that will open a query [qry1] hidden and then copy the single record that is filtered to be pasted some where else then closes the query [qry1]. Please help
 
I need a copy button [COPYBttn] on a form that will open a query [qry1] hidden and then copy the single record that is filtered to be pasted some where else then closes the query [qry1]. Please help
 
Hi

The DLookup function will do just that.

For example:

If you have a table named ATable with two fields:
TheFieldYouWant field and TheFilterField field

and a query named qry1
qry1="SELECT ATable.TheFieldYouWant, ATable.TheFilterField FROM ATable;"

On a form you have a textbox named text1 and a commandbutton named COPYBttn

The following code in the onClick event of COPYbttn will put the filtered results into text1:

Dim aFld
aFld = DLookup("[TheFieldYouWant]", "qry1", " [TheFilterField] ='AFilterCriterion'")
Me!Text1 = aFld

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top