By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,299 Members | 1,228 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,299 IT Pros & Developers. It's quick & easy.

Opening a filtered form on two different data type fields

P: 2
I am trying to open a form based on the record set of the current form. The form I am opening should filtered based on a text field and a date field. The code I am using is as follows:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command100_Click()
  2. If Not Me.NewRecord Then
  3.     DoCmd.OpenForm "FrmPulls", , , "[TEXT]='" & Me!TEXT & "'" And "[DATE]=#" & Me!DATE & "#", , acWindowNormal
  4. End If
  5. End Sub
When I run the code I receive the error message "Run-time error '13': Type mismatch".

When I hover over the arguments in debug mode the data is correct. What is causing this error message??

Thanks
Feb 26 '08 #1
Share this Question
Share on Google+
2 Replies


Expert Mod 2.5K+
P: 2,545
...When I run the code I receive the error message "Run-time error '13': Type mismatch".
HI Tadel714. It's the quote marks in your filter string which are causing the problem - the AND is not within the string at present:
Expand|Select|Wrap|Line Numbers
  1. "[TEXT]='" & Me!TEXT & "'" And "[DATE]=#" & Me!DATE & "#", , 
Change it to
Expand|Select|Wrap|Line Numbers
  1. "[TEXT]='" & Me!TEXT & "' And [DATE] = #" & Me!DATE & "#", , 
-Stewart
Feb 26 '08 #2

P: 2
HI Tadel714. It's the quote marks in your filter string which are causing the problem - the AND is not within the string at present:
Expand|Select|Wrap|Line Numbers
  1. "[TEXT]='" & Me!TEXT & "'" And "[DATE]=#" & Me!DATE & "#", , 
Change it to
Expand|Select|Wrap|Line Numbers
  1. "[TEXT]='" & Me!TEXT & "' And [DATE] = #" & Me!DATE & "#", , 
-Stewart
That worked, thanks Stewart
Feb 27 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.