Hey guys. Noob Here. I have been searching for a while but just can't come to a conclusion. Need some help.
I am creating a form to add new records from a click event. I think I have the query pinned down but I'm getting "Data type mismatch in criteria expression" when i try to execute.
txtPointName allows a user to enter a point name
txtTPID = the result of a Dlookup which runs the query to return the max(trendedpointid)+1
cboUnitType = a value list of 3 numbers
Fields:
TrendedPointID = int
UnitTypeID = int
TrendedPointName = varchar
ModBy = varchar
ModDt = date/time
I'm sure I need to do a conversion somewhere, somehow, but am unsure of where and what the syntax would be. Any help would be appreciated.
Code:
Private Sub cmdAddPoints_Click()
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb()
Set qdf = db.QueryDefs("qryAddPoint")
strCriteria = Right(strCriteria, Len(strCriteria) - 1)
strSQL = "INSERT INTO dbo_TrendedPointLookup ( TrendedPointId, UnitTypId, TrendedPointName, ModBy, ModDt ) " & _
"VALUES(' & Me!txtTPID & ' AS Expr1, ' & cboUnitType & ' AS Expr2, '" & txtPointName & "' AS Expr3, 'Admin' AS Expr4, Now() AS Expr5);"
qdf.SQL = strSQL
DoCmd.OpenQuery "qryAddPoint"
Set db = Nothing
Set qdf = Nothing
End Sub