drtopserv
asked on
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 "frmShowAllBigClientsOrder s", acNormal, , "[Date = #" & Format(Me.cboBigClientsOrd ersDate, "mm/dd/yyyy") & "#" And "ExportBankBigClientsStatu s = " & Me.cboExportBankBigClients Status, acFormReadOnly, acWindowNormal
I got an error :
type mismatch
how can i fix it ?
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 "frmShowAllBigClientsOrder
I got an error :
type mismatch
how can i fix it ?
There should be a ] after Date.
ASKER
sorry yea sure it is there, still have type mismatched
i just mis-typed here not in the real code in the form
i just mis-typed here not in the real code in the form
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
@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.cboBigClientsOrd ersDate, "mm/dd/yyyy") & "#" _
& " And [ExportBankBigClientsStatu s] = " & Me.cboExportBankBigClients Status
debug.print strCriteria
DoCmd.OpenForm "frmShowAllBigClientsOrder s", 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.
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.cboBigClientsOrd
& " And [ExportBankBigClientsStatu
debug.print strCriteria
DoCmd.OpenForm "frmShowAllBigClientsOrder
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.
You need to check for valid field values. Are the fields blank perhaps? Empty date might give that kind of error.
ASKER
@Gustav Brock
your code works!!
how did u change in it?
and what is the \/ thing in date is for?
your code works!!
how did u change in it?
and what is the \/ thing in date is for?
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
This way the date expression will always be, say, 2015/10/11 which never will fail neither in SQL nor ADO.
/gustav
ASKER
works as a charm