JustPunkin
Registered User.
- Local time
- Today, 18:46
- Joined
- Jan 8, 2009
- Messages
- 38
OK, bear with me. I am a total novice at this stuff (access, SQL, vb). I am working on creating a form that will allow me to query our project database based on several varying criteria. I get the idea of creating a query on the fly, and I can get this to work for the data we have that is in combo boxes. What I can't get to work is the data that we have in check boxes (yes/no data type).
This is the start of my routine
When I pop the SQL string into a query to test it, I get a data type mismatch in criteria expression error. I've narrowed it down to the check boxes (which are the tile deck and foldover weirs fields).
When I check the SQL string after running it with criteria, I get this:
which looks to be correct to me (on the form I had selected yes for Tile Deck and no for Foldovers). But it won't let me run the query.
Any ideas what I'm doing wrong? Remember, I'm a total noob when it comes to this stuff, so be gentle!
This is the start of my routine
Code:
Private Sub cmdOK_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryTest1")
strSQL = "SELECT [Mechanical Features].* " & _
"FROM [Mechanical Features] " & _
"WHERE [Mechanical Features].[Fastener Type]='" & Me.cboFastType.Value & "'" & _
"AND [Mechanical Features].[MW Design]='" & Me.cboMWDesign.Value & "'" & _
"AND [Mechanical Features].[Tile Deck]='" & Me.chkTileDeck.Value & "'" & _
"AND [Mechanical Features].[Foldover weirs]='" & Me.chkFOWeir.Value & "'" & _
"ORDER BY [Mechanical features].[Fastener Type];"
Debug.Print strSQL
End Sub
When I check the SQL string after running it with criteria, I get this:
Code:
SELECT [Mechanical Features].*
FROM [Mechanical Features]
WHERE [Mechanical Features].[Fastener Type]='UNC' And [Mechanical Features].[MW Design]='Oval' And [Mechanical Features].[Tile Deck]='-1' And [Mechanical Features].[Foldover Weirs]='0'
ORDER BY [Mechanical features].[Fastener Type];
Any ideas what I'm doing wrong? Remember, I'm a total noob when it comes to this stuff, so be gentle!