Code:
Private Sub cmdPMIDo_Click()
'Declare variables
Dim passModel As Variant
Dim lookupPMI As Variant
'Declare values
passModel = Me.AssetSearchSub.Form.Model
lookupPMI = DLookup("[ModelNumber]", "PMIQuery", "[ModelNumber]= " ' & passModel &"' ") <= Error
'Compare ModelNumber of currently selected record with PMIQuery, then append date info as necessary
If passModel = lookupPMI Then
Me.AssetSearchSub.Form.LastPMIDate = DateValue(Now())
Me.AssetSearchSub.Form.NextPMIDate = LastPMIDate + DLookup("PMIFrequency", "PMITasks", "[ModelNumber]='" & passModel & "'")
End If
End Sub
You have a single quote in the wrong place in the first Dlookup(). See the underline in the above code.
"Now()" is the date and time. If you want only the date, use "Date()".
I modified your code a little. See if this works:
Code:
Private Sub cmdPMIDo_Click()
'Declare variables
Dim passModel As String
Dim lookupPMI As String
Dim Freq as Integer
'Declare values
passModel = Me!AssetSearchSub.Form!Model
lookupPMI = DLookup("[ModelNumber]", "PMIQuery", "[ModelNumber]= '" & passModel &"'")
'Compare ModelNumber of currently selected record with PMIQuery, then append date info as necessary
If passModel = lookupPMI Then
Freq = DLookup("PMIFrequency", "PMITasks", "[ModelNumber]='" & passModel & "'")
Me!AssetSearchSub.Form!LastPMIDate = Date()
Me!AssetSearchSub.Form!NextPMIDate = DateAdd("d", Freq, Date())
End If
End Sub
Single step through the code to see what values are returned