Command button on form needs query, code, something...

M

Mary A Perez

I have a form where it's code for a user to choose from a combo box drop down
a name of a contract. Then the next combo box drop down choice for the user
is the name of the rate sheet specific to the contract name. That code is
fine.
What I need help with is the command button the user will use next. It's
called "Click here for Contract Information". Once clicked in a perfect
world, the user will be taken to the specifc rate sheet that was chosen at
the second drop down.
How do I code or query for the command button to do this?
Thank you
 
O

Ofer

In a query you can reference to the combo

Select * From [rate Table Name] Where [rate Field Name] =
Forms![MainFormName]![RateComboName]

Or, if you open anther form with the details, then use the where condition
in the open form command line

Dim MyWhereCond As String
MyWhereCond = "[rate Field Name] = " & Me.[RateComboName]
Docmd.OpenForm "FormName",,,MyWhereCond

If the rate field is string, change the where condition to
MyWhereCond = "[rate Field Name] = '" & Me.[RateComboName] & "'"
 
M

Mary A Perez

Sorry, but I'm not that great at this.
Here is the command button code as it is now. Can you tell me where to put
the code within this code to open the form directly related to the contract
name and contract rate sheet name chosen by the user.
Thank you.

Private Sub cmdClickforContractInformation1_Click()
On Error GoTo Err_cmdClickforContractInformation1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmContractRates-Specifications"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_cmdClickforContractInformation1_Cli:
Exit Sub

Err_cmdClickforContractInformation1_Click:
MsgBox Err.Description
Resume Exit_cmdClickforContractInformation1_Cli

End Sub



Ofer said:
In a query you can reference to the combo

Select * From [rate Table Name] Where [rate Field Name] =
Forms![MainFormName]![RateComboName]

Or, if you open anther form with the details, then use the where condition
in the open form command line

Dim MyWhereCond As String
MyWhereCond = "[rate Field Name] = " & Me.[RateComboName]
Docmd.OpenForm "FormName",,,MyWhereCond

If the rate field is string, change the where condition to
MyWhereCond = "[rate Field Name] = '" & Me.[RateComboName] & "'"

--
\\// Live Long and Prosper \\//
BS"D


Mary A Perez said:
I have a form where it's code for a user to choose from a combo box drop down
a name of a contract. Then the next combo box drop down choice for the user
is the name of the rate sheet specific to the contract name. That code is
fine.
What I need help with is the command button the user will use next. It's
called "Click here for Contract Information". Once clicked in a perfect
world, the user will be taken to the specifc rate sheet that was chosen at
the second drop down.
How do I code or query for the command button to do this?
Thank you
 

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