I'm getting a data type mismatch error, but I can't seem to fix it
Code:
Dim s As Strings = InputBox("What is the Work Order number?", "Work Orders")
Dim qry As QueryDef
Dim strSQL As String
strSQL = "SELECT * FROM [Master Table] WHERE [Work Order #] = " & s
If QueryExists("QRY_MYQUERY") = True Then
CurrentDb.QueryDefs.Delete "QRY_MYQUERY"
Set qry = CurrentDb.CreateQueryDef("QRY_MYQUERY", strSQL)
Else
Set qry = CurrentDb.CreateQueryDef("QRY_MYQUERY", strSQL)
End If
Dim x As Integer
Dim y As Double
x = Nz(DMax("[Change Request #]", "QRY_MYQUERY", ""), 0)
Me.Text169 = x
y = Nz(DLookup("[Total Work Order Amount]", "QRY_MYQUERY", "[Change Request #] = " & x), 0)
Me.Text171 = y
strSQL = "SELECT * FROM [Master Invoice Table] WHERE [Work Order] = " & s
If QueryExists("QRY_MYQUERY") = True Then
CurrentDb.QueryDefs.Delete "QRY_MYQUERY"
Set qry = CurrentDb.CreateQueryDef("QRY_MYQUERY", strSQL)
Else
Set qry = CurrentDb.CreateQueryDef("QRY_MYQUERY", strSQL)
End If
Dim z As Double
z = Nz(DSum("[Invoice Amount]", "QRY_MYQUERY"), 0)
Me.Text710 = z
Me.Text712 = y - z
The bolded part gives the error. z = Nz(DSum("[Invoice Amount]", "QRY_MYQUERY"), 0)
I've tried changing z to integer and currency, but I don't understand why it'd be giving a type mismatch
EDIT: Rookie mistake, I forgot to change the Work Order in Master Invoice Table to Number instead of Text