Hi all,
I have a Table: tblDemandForcast
With Fields:
Date (as Date)
D -1 (as number)
D -2 (as number)
D -3 (as number)
D -4 (as number)
D -5 (as number)
D -6 (as number)
I then have a form, frmDemandForcasting, that has an unbound date field (txtRepDate) and fields D -1 through to D -6 (named in that style) bound to the tblDemandForcast.
I am trying to perform a check to see if a record exists for the date in txtRepDate, I have the code bewlow, but it does not seem to be working.
Could anyone help shed some light upon this?
Many thanks
I have a Table: tblDemandForcast
With Fields:
Date (as Date)
D -1 (as number)
D -2 (as number)
D -3 (as number)
D -4 (as number)
D -5 (as number)
D -6 (as number)
I then have a form, frmDemandForcasting, that has an unbound date field (txtRepDate) and fields D -1 through to D -6 (named in that style) bound to the tblDemandForcast.
I am trying to perform a check to see if a record exists for the date in txtRepDate, I have the code bewlow, but it does not seem to be working.
Could anyone help shed some light upon this?
Many thanks
Code:
If IsNull(DLookup("[Date]", _
"[tblDemandForcast]", _
"[Date]=#" & Me!txtRepDate & "#")) Then
MsgBox "Duplicate!"
Else
DoCmd.RunSQL "INSERT INTO [tblDemandForcast] " & _
"([Date],[D -1],[D -2],[D -3],[D -4],[D -5],[D -6]) " & _
"VALUES (#" & Me!txtRepDate & "#," & Me![D -1] & Me![D -2] & Me![D -3] & Me![D -4] & Me![D -5] & Me![D -6] & ")"
Call Me.Requery
End If