Need code for command buttons

M

Mary A Perez

I have a form where the user will choose a Plan Name, then a Product Name
that correlates to the Plan. Once this is chosen, the user will then choose
one of three command buttons to click on to give them either current rate
form, current amendment rate form, or previously effective rate form.
What I need is the code for the "on click" event of the command button so
that it will go to the form based upon the plan and product chosen.
I have the following tables:
tblPlan(PlanId is the primary key & is an auto-number data type)
tblProduct(ProductId is the primary key & is an auto-number data type)
tblCurrentContractRatesandSpecifications(ProductName is the primary key)
tblCurrentContractAmendmentRatesandSpecifications(ProductName is the primary
key)
tblPreviousEffectiveContractRatesandSpecifications(ProductName is the
primary key)
I have the following forms:
frmPlanProductChoices(this is the form where the user will choose the plan
and the product & the rate form)
frmCurrentContractRatesandSpecifications(built from the tbl with the
corresponding name)
frmCurrentContractAmendmentRatesandSpecifications
frmPreviousEffectiveContractRatesandSpecifications
The above forms are the forms I want the user to go to upon the "on click"
of the followng command buttons within the frmPlanProductChoices:
cmdCurrentContractRatesandSpecifications
cmdCurrentContractAmendmentRatesandSpecifications
cmdPreviousEffectiveContractRatesandSpecifications

Thanks to whomever reads this & helps me move forward with my database.
 
K

Klatuu

Just put the code to open a form in the Click event of each command button.
If you need to know how to do that, look up the OpenForm method in the VB
Editor Help, or in the Object Browser.
 
M

Mary A Perez

How do I write the code, so that the plan and product chosen drives the
correct form when the command button is clicked?
 
K

Klatuu

Sorry, Mary, I am having a little trouble understanding the question. Are
you saying that once you choose a form to open, you want the Plan and Product
chosen on frmCurrentContractRatesandSpecifications to be the current record
in the chosen form? If so, then you need to use the Where Condition argument
of the OpenForm method:
DoCmd.OpenForm "frmCurrentContractRatesandSpecifications", , ,"PlandId = '" _
& Me.txtPlanId & "' And ProductID = '" & Me.txtProductID & "'"

txtPlanID and txtProductId are names I made up. They should be the names of
the controls where you enter the data on
frmCurrentContractRatesandSpecifications.
Also, If either the PlanId or ProductId fields in your table are numeric,
leave out the single quotes for the one(s) that are numeric. Here is an
example assuming they are both numeric:
DoCmd.OpenForm "frmCurrentContractRatesandSpecifications", , ,"PlandId = " _
& Me.txtPlanId & " And ProductID = " & Me.txtProductID

Good Luck!
 
M

Mary A Perez

Thank you

Klatuu said:
Sorry, Mary, I am having a little trouble understanding the question. Are
you saying that once you choose a form to open, you want the Plan and Product
chosen on frmCurrentContractRatesandSpecifications to be the current record
in the chosen form? If so, then you need to use the Where Condition argument
of the OpenForm method:
DoCmd.OpenForm "frmCurrentContractRatesandSpecifications", , ,"PlandId = '" _
& Me.txtPlanId & "' And ProductID = '" & Me.txtProductID & "'"

txtPlanID and txtProductId are names I made up. They should be the names of
the controls where you enter the data on
frmCurrentContractRatesandSpecifications.
Also, If either the PlanId or ProductId fields in your table are numeric,
leave out the single quotes for the one(s) that are numeric. Here is an
example assuming they are both numeric:
DoCmd.OpenForm "frmCurrentContractRatesandSpecifications", , ,"PlandId = " _
& Me.txtPlanId & " And ProductID = " & Me.txtProductID

Good Luck!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top