Need help with a form?

A

Andre

Hi

I hope someone can help me out with this problem. I am trying to create 2
cmd buttons on a form, button one must call a query which must pull data from
a table and insert it in another table, at the same time when the button is
pressed it must insert a column in the table and update it with name
"comapany A". Button two must do the same as button one, except it must
enter the name "company B" in the same table.

Any help or advice will be greatly appreciated.
 
K

Klatuu

Put a hidden (Visible = No) text box on your form where you can put the
company name when the user clicks one of the command buttons.

Use the query builder to build your append query. In the column where you
want to put the Company name, use a Calculated Field that will reference the
hidden ontrol on your form.

CompanyName: Forms!MyForm!txtCompanyName

Write a function that will run the query

Private Function SelectCompany()

Me.txtCompanyName = Screen.ActiveControl.Caption
Currentdb.Execute "MyQueryName" , dbFailOnError
End Function

Make the Captions of your comman buttons the value you want to put in the
column, for example "Company A" and "Company B"

In the Click Event text box of the Properties Dialog for both command buttons:
=SelectCompany()

That's all there is to it!
 
Top