473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DoCmd Open form error on filter

Hey all, everytime I open the form Clickform with a button, I keep getting a runtime error 3464- data type mismatch in criteria expression with the DoCmd line highlighted.

Basically I have a group of checkboxes (Check1, Check2, etc.) on a form called Check, and the code filters through the checkboxes to see which ones are checked. Once the user clicks the button (called Command0), it opens up the Clickform and applies a filter based on the checkboxes. For instance, if Check3 and Check4 are highlighted, then the Checkform will be filtered on the records where Door=4 or Door=5. Here's my code:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Base 1
  3.  
  4. Private Sub Command0_Click()
  5.  
  6. Dim Ctrl As Object, i, j, RecsChose, ThisChkbox, ErrMess, sqlStr, sqlPl
  7. Dim Narr() As Variant
  8.  
  9. ThisChkbox = 0
  10. i = 0
  11.  
  12. For Each Ctrl In Me.Controls
  13.     If (Ctrl.ControlType = 106) Then
  14.         ThisChkbox = Ctrl.Value
  15.         If ThisChkbox Then
  16.         i = i + 1
  17.         ReDim Preserve Narr(i)
  18.         Narr(i) = Ctrl.DefaultValue
  19.         End If
  20.     End If
  21. Next
  22.  
  23. If i > 0 Then
  24.     For j = 1 To UBound(Narr) - 1
  25.         RecsChose = RecsChose & "Trailers_Unloading_LA.Door=" & Narr(j) & " OR "
  26.     Next
  27.     RecsChose = RecsChose & "Trailers_Unloading_LA.Door=" & Narr(j) & ";"
  28.     sqlP1 = "SELECT Trailers_Unloading_LA.Door, Trailers_Unloading_LA.Trailer_Number, Trailers_Unloading_LA.LA01, Trailers_Unloading_LA.LA02, Trailers_Unloading_LA.LA03, Trailers_Unloading_LA.LA04, Trailers_Unloading_LA.LA05, Trailers_Unloading_LA.LA06, Trailers_Unloading_LA.LA07, Trailers_Unloading_LA.LA08, Trailers_Unloading_LA.LA09, Trailers_Unloading_LA.LA10 FROM Trailers_Unloading_LA WHERE "
  29.     sqlStr = sqlP1 & RecsChose
  30.     Else
  31.     ErrMess = MsgBox("No trailers are being unloaded", vbOKOnly, "Status")
  32. End If
  33.  
  34. Debug.Print sqlStr
  35.  
  36. DoCmd.OpenForm "CheckForm", acNormal, sqlStr, , acFormReadOnly, acWindowNormal
  37.  
  38. End Sub
  39.  
Any ideas why this is not working? I can't seem to figure it out after scouring the internet looking for reasons why it might not be working..
Jan 30 '12 #1

✓ answered by Rabbit

Is Door a string? If so you need to surround the values in quotes.

4 3341
Rabbit
12,516 Expert Mod 8TB
Is Door a string? If so you need to surround the values in quotes.
Jan 30 '12 #2
Ahhh yes, something so simple. Thanks rabbit.
Jan 30 '12 #3
Rabbit
12,516 Expert Mod 8TB
Sure thing, good luck.
Jan 30 '12 #4
NeoPa
32,556 Expert Mod 16PB
Ben, Here's a couple of links for you.
  1. Quotes (') and Double-Quotes (") - Where and When to use them
  2. When Posting (VBA or SQL) Code

A should prove helpful with similar issues in future.
B I would like (as a moderator) to ask you to read before posting code again. Never worry. You'll get much more from it than we will - it's a win-win for all. Using code with no Option Explicit line is just a recipe for problems for you.
Jan 30 '12 #5

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

Similar topics

1
by: Dave Elliott | last post by:
I have a form named Add Products where I enter Products with a Category ID, Category Name & Category Description. I want the form to open showing only the records assocated with the Category Labor...
1
by: P | last post by:
Hi, Access 2002. I am trying to use the PrintOut function to print the current record of the current open form in landscape format to the default Windows printer. Any suggestion on how to set...
2
by: allyn44 | last post by:
Hello, I have built a serch form for users to edit records. I only want them to pull up the record they need, and I want to check for nulls. There should not be dupes becasue the underlying...
9
by: StellaUK | last post by:
I have Seen Loads Of Post On This And I Have Spent The Last Hour Trying Everything I Come Across But Still Can Get What I Thought Was A Simple Thing To Work .. LOL I Have 2 Forms Vehicles...
3
by: kev | last post by:
Hi folks, I have a form for registration (frmRegistration) whereby i have two buttons. One is Save which saves record using the OnClick property. I used wizard to create the save button. The...
14
by: keri | last post by:
Hi, Simple version of the question..... How do I use the where clause of the open form command to show an account with a matching ID to be displayed when the form is opened? Eg. I select a...
4
by: SDave | last post by:
I have read several responses to this problem around the web, but my programming knowledge wasn't strong enough to translate those responses to my problem. I have a database with one table, the...
10
by: Beatrice | last post by:
I need to open a form selecting all data from a previous form i.e: Form 1) combo box 1 named "cboYearSelect" displayed as "Year" based on qry QryYearList ( only one field "Year") ...
5
by: Lebbsy | last post by:
After displaying search results, I want to be able to double click the identity number field and then the input form SubmissionDetails becomes the display form for the results of the data matching...
2
by: Ian Anderson | last post by:
Hello there, SO i have the followign VB code in my continuous form... 'Purpose: This module illustrates how to create a search form, _ where the user can enter as many or few...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.