Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 3464 Data type mismatch in criteria expression

Status
Not open for further replies.

AlanJordan

Programmer
Sep 15, 2005
139
US
Can anyone tell me why this code is suddenly producing a 3464 error? "Data type mismatch in criteria experession." I have changed the data, so that might be causing the problem. Do you think it is trying to coerce a vbnullstring into a double and having trouble. If so, what should I do to change it? I've tried a few things without success.

Alan
Code:
    'If the difference is a negative amount AND if it is an adjusted item, it is a mistake.
    
    If Not IsNull(Me.AWPDiffIn1.Value) Then
        If Me!AWPDiffIn1.Value <> "" Then
            If CDbl(Me.AWPDiffIn1.Value) < 0 And Me.chkAWPInAdj1.Value = True Then
                boolDiffFlag1 = True
            End If
        End If
    End If
 
You stated you changed some data types but left us guessing what these changes might have been. You also don't tell us which line of code is causing the error.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Dear dhookom,

Thank you for your response.

I am now encountering a 3464 error in two places. One is in the code above. The problem occurs on the first line of the code.

I took a good look at the form and the code, and I found that the name of the text boxes was incorrect, so I changed the code as follows:
Code:
    If Not IsNull(Me!txtAWPInDiff1.Value) Then 'txtAWPInDiff1
        If CDbl(Me!txtAWPInDiff1.Value) < 0 And Me.chkAWPInAdj1.Value = True Then
            boolDiffFlag1 = True
        End If
    End If
    If Not IsNull(Me!txtAWPInDiff2.Value) Then
        If CDbl(Me!txtAWPInDiff2.Value) < 0 And Me.chkAWPInAdj2.Value = True Then
            boolDiffFlag2 = True
        End If
    End If
    If Not IsNull(Me!txtAWPInDiff3.Value) Then
        If CDbl(Me!txtAWPInDiff3.Value) < 0 And Me.chkAWPInAdj3.Value = True Then
            boolDiffFlag3 = True
        End If
    End If
    If Not IsNull(Me!txtAWPInDiff4.Value) Then
        If CDbl(Me!txtAWPInDiff4.Value) < 0 And Me.chkAWPInAdj4.Value = True Then
            boolDiffFlag4 = True
        End If
    End If

Interestingly, I get exactly the same results. If you'd like, I can post a screen capture.

Even more interesting is the fact that this code just stopped working. When I go back into archived versions of my program, it works.

Also . . .

The second place is when I run a sub that calls another query, qry_p_EesWithHoursCalced_PP_Week
This has the following SQL:
Code:
SELECT DISTINCT qryEmployeesWithHoursWorked.LastName, qryEmployeesWithHoursWorked.FirstName, qryEmployeesWithHoursWorked.KKLogin, qryEmployeesWithHoursWorked.PayCode, qryEmployeesWithHoursWorked.LogIn1Bldg AS B1, qryEmployeesWithHoursWorked.LogIn2Bldg AS B2, qryEmployeesWithHoursWorked.LogIn3Bldg AS B3, qryEmployeesWithHoursWorked.LogIn4Bldg AS B4, qryCalcTimeWorkedWithHoursWrked.HW1, qryCalcTimeWorkedWithHoursWrked.HW2, qryCalcTimeWorkedWithHoursWrked.HW3, qryCalcTimeWorkedWithHoursWrked.HW4, TotB3Hours([B1],[B2],[B3],[B4],[HW1],[HW2],[HW3],[HW4]) AS HW_Bldg3, TotB2Hours([B1],[B2],[B3],[B4],[HW1],[HW2],[HW3],[HW4]) AS HW_Bldg2, TotB1Hours([B1],[B2],[B3],[B4],[HW1],[HW2],[HW3],[HW4]) AS HW_Bldg1, [HW_Bldg1]+[HW_Bldg2] AS HW_Bldg1_2, qryCalcTimeWorkedWithHoursWrked.DateWorkPerformed, InWeekNumber([qryCalcTimeWorkedWithHoursWrked.DateWorkPerformed]) AS WeekNumber, EmpData.Department, qryCalcTimeWorkedWithHoursWrked.ClockedHrsWorked, qryCalcTimeWorkedWithHoursWrked.PremiumHW, CalcDailyPremHW([PremiumHW]) AS PremiumOP, [PremiumHW]-[PremiumOP] AS NewPremHW
FROM EmpData INNER JOIN (qryEmployeesWithHoursWorked INNER JOIN qryCalcTimeWorkedWithHoursWrked ON (qryEmployeesWithHoursWorked.DateWorkPerformed = qryCalcTimeWorkedWithHoursWrked.DateWorkPerformed) AND (qryEmployeesWithHoursWorked.KKLogin = qryCalcTimeWorkedWithHoursWrked.KKLogin)) ON EmpData.EmployeeNumber = qryCalcTimeWorkedWithHoursWrked.KKLogin
WHERE (((InWeekNumber([qryCalcTimeWorkedWithHoursWrked.DateWorkPerformed]))=[Enter Week Number]) AND ((IsInPayPeriod([qryEmployeesWithHoursWorked].[DateWorkPerformed]))=[Enter Pay Period]));

I am trying to be concise, and I hope these explanations are helpful.

Alan
 
I can't imagine:
[li]what your table structures might be[/li]
[li]what your functions are[/li]
[li]why with this amount of complexity, you use parameter prompt queries[/li]

Can you tell us what you are attempting to do with all of this?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top