Type mismatch access vba

Hi,
Well i wanna open a form in access 2010 with parameter from controls in other form .

in "on click even" in a control in a main form i have this code :

DoCmd.OpenForm "frmShowAllBigClientsOrders", acNormal, , "[Date = #" & Format(Me.cboBigClientsOrdersDate, "mm/dd/yyyy") & "#" And "ExportBankBigClientsStatus = " & Me.cboExportBankBigClientsStatus, acFormReadOnly, acWindowNormal
I got an error :
type mismatch
how can i fix it ?
drtopservAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NorieVBA ExpertCommented:
There should be a ] after Date.
0
drtopservAuthor Commented:
sorry yea sure it is there, still have type mismatched
i just mis-typed here not in the real code in the form
0
Gustav BrockCIOCommented:
This should do:

DoCmd.OpenForm "frmShowAllBigClientsOrders", acNormal, , "[Date] = #" & Format(Me!cboBigClientsOrdersDate.Value, "yyyy\/mm\/dd") & "# And [ExportBankBigClientsStatus] = " & Me!cboExportBankBigClientsStatus.Value & "", acFormReadOnly, acWindowNormal

If ExportBankBigClientsStatus is text, you also need quotes:

DoCmd.OpenForm "frmShowAllBigClientsOrders", acNormal, , "[Date] = #" & Format(Me!cboBigClientsOrdersDate.Value, "yyyy\/mm\/dd") & "# And [ExportBankBigClientsStatus] = '" & Me!cboExportBankBigClientsStatus.Value & "'", acFormReadOnly, acWindowNormal

/gustav
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Dale FyeCommented:
@drtopserv,

One of the ways I use to debug this type of error is that I generally define the criteria string outside the OpenForm method.  This allows me to add a debug.print statement before the OpenForm method.

Dim strCriteria as string

strCriteria = "[Date] = #" & Format(Me.cboBigClientsOrdersDate, "mm/dd/yyyy") & "#"  _
                   & " And [ExportBankBigClientsStatus] = " & Me.cboExportBankBigClientsStatus
debug.print strCriteria
DoCmd.OpenForm "frmShowAllBigClientsOrders", acNormal, , strCriteria, acFormReadOnly, acWindowNormal

When I'm developing, I will generally put a breakpoint on the OpenForm line and examine the output of the print command in the immediate window before I execute the OpenForm.  This way, I can make edits to the criteria string, and move the focus back to that line to get it right before opening the new form.
0
Jerry_JusticeCommented:
You need to check for valid field values. Are the fields blank perhaps? Empty date might give that kind of error.
0
drtopservAuthor Commented:
@Gustav Brock
your code works!!
how did u change in it?
and what is the \/ thing in date is for?
0
Gustav BrockCIOCommented:
The backslash is the escape character that forces the following character, the slash, to be read literally. Otherwise, the slash would be read as the date separator which isn't always a slash but can be a hyphen - even a space.
This way the date expression will always be, say, 2015/10/11 which never will fail neither in SQL nor ADO.

/gustav
1
drtopservAuthor Commented:
works as a charm
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.