From: Dirk Goldgar on
"niuginikiwi" <niuginikiwi(a)discussions.microsoft.com> wrote in message
news:77A71B1E-F7EE-441F-B41C-64DF83889FDE(a)microsoft.com...
> Hi Dirk,
>
> ProductName and cboSupplier fields cannot be null. They have to be filled
> in.
> However, I want the record to go ahead if they were nulls BUT will only
> throw the duplication message when the DCount function finds another
> existing
> record and then decide from the vbYesNo.
> Yes to add and No to undo.
>
> what seems to be happening is as soon as an entry is made the procedure
> checks those fields and detects the nulls and throws the syntax error.
>
> Maybe this code should go under the before update event of the form??
>
> All I want to achieve here is to look at the current record that is
> added/edited and make sure it does not match the combination of criteria
> supplied and if it does, prompt the vbYesNo message box and if it isn't go
> and save the record.

So, if one of the controls is Null, do you want to consider it to match a
record that has a Null in in that field, or do you not want to include it in
the matching at all?

Regardless, the BeforeInsert event is no good for this, because it fires
when the user first begins to edit data in a new record. Instead, you'll
want to use the BeforeUpdate event, but put all this logic in a conditional
block that tests whether this is a new record ("If Me.NewRecord Then ...").

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)