Re: Code isn't opening chosen form.



Well, Allen.
I did what you said. It is text so I kept the extra quotes.
Then I did the Debug.Print & received the following:
[PlanName]= '1' and [ProductName]= '1'
The SQL view:
WHERE ((([tblCurrentRates-SpecificationsMain-South].PlanName)="Aetna") AND
(([tblCurrentRates-SpecificationsMain-South].ProductName)="AETUS HMO"));

So, it looks ok to me, but I'm not sure I know what I'm doing. So what do
you think?
Thanks for your time.

"Allen Browne" wrote:

> If you open your table in design view, what data type are PlanName and
> ProductName?
>
> If they are Number type fields (not Text type fields), drop the extra
> quotes, i.e.:
>
> stLinkCriteria = "([PlanName]= " & Me.cmbPlan & ") AND [ProductName]= " &
> Me.cmbProduct & ")"
>
> The brackets are optional. If it still doesn't work, add:
> Debug.Print stLinkCriteria
> on the next line. Then when it fails to work correctly, open the Immediate
> Window (Ctrl+G) and see what it printed there. Compare it it what you get in
> the WHERE clause if you mock up a query and switch it to SQL View (View
> menu, from query design view.)
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia.
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Mary A Perez" <MaryAPerez@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:BE1F7511-6328-4622-9402-5B0379D5F759@xxxxxxxxxxxxxxxx
> > Below is a code that will open the form upon clicking the command button
> > for
> > that form. The form that opens is to be based upon the Plan and Product
> > names chosen from the drop down combo boxes prior to clicking on the form
> > command button.
> > The form opens, but does not open to the chosen Plan and Product name.
> > What can I do to fix this?
> >
> > Thanks in advance for your help.
> >
> > Private Sub cmdCurrentContractRatesandSpecifications_Click()
> > On Error GoTo Err_cmdCurrentContractRatesandSpecifications_Click
> >
> > Dim stDocName As String
> > Dim stLinkCriteria As String
> >
> > stDocName = "frmCurrentRates-SpecificationsMain-South"
> > stLinkCriteria = "[PlanName]= '" & Me.cmbPlan & "' and [ProductName]=
> > '"
> > & Me.cmbProduct & "'"
> > DoCmd.OpenForm stDocName, , , stLinkCriteria
> >
> > Exit_cmdCurrentContractRatesandSpecifica:
> > Exit Sub
> >
> > Err_cmdCurrentContractRatesandSpecifications_Click:
> > MsgBox Err.Description
> > Resume Exit_cmdCurrentContractRatesandSpecifica
> >
> > End Sub
>
>
>
.