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

Do.Cmd Open Form WHERE question

P: 2
Hello, this is my first post. Thanks for reading.

I am trying to open a form on a Click event where the records displayed are what the user has selected on several form combo boxes. Some of the combo boxes contain text and some numbers. I am getting a data mismatch erorr in Ac07 when I try to combine both data types in the same Where condition. Here is my code:

Expand|Select|Wrap|Line Numbers
  1. Dim strWhere As String
  2.  
  3. strWhere = "[ID] = " & Me.cboID Or "[Type] = '" & Me.cboType & "'"
  4.  
  5. DoCmd.OpenForm "MyForm", , , strWhere, acFormEdit
  6.  
Could it be because I am declaring this as a string? I tried a CInt(ID) but that didn't seem to work, but maybe my syntax was wrong.

Thank you for your help!
May 10 '10 #1
Share this Question
Share on Google+
3 Replies


Megalog
Expert 100+
P: 378
The string wasnt being built correctly, try this instead:
Expand|Select|Wrap|Line Numbers
  1. strWhere = "[ID] = " & Me.cboID & " Or [Type] = '" & Me.cboType & "'"
May 10 '10 #2

P: 2
That's the winner, thanks for your quick help!
May 10 '10 #3

Megalog
Expert 100+
P: 378
Glad to help! Hope all your future questions go this quickly ;)

Welcome to Bytes!
May 10 '10 #4

Post your reply

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