B
Bruce
I received some code here to prevent duplicate entries in
two fields, but I think the first part of the code assumes
a different data type than I am using.
I have a table (tblDocument), and a form (frmDocument)
based on the table. tblDocument contains fields [DocNum]
and [Revision]. The corresponding text boxes on
frmDocument are txtDocNum and txtRevision. I need a
message box to pop up if both fields match another
record. If DocNum 123, Revision A exists, a new record
can contain DocNum123 only if Revision is something other
than A. Both [DocNum] and [Revision] are text fields.
The code I have (which is wrong, but I wonder if I am even
close) is (underscore means no line break):
If DCount("*", "tblDocument", "txtDocNum = " &_
Me.DocNum & " AND txtRevision = ' " & Me.Revision_
& " ' ") > 0 Then
MsgBox ...
and the rest of the code is OK. I am pretty sure I need
some single quotes in the first part, since it is text,
but I can't find the combination that works. The trouble
is that I can't tell to which part of the expression the
quotes belong. The other trouble is that in VBA field
names, etc. are sometimes in brackets, sometimes in
quotes, and probably some other options as well. If there
is a pattern, I have not yet discovered it.
two fields, but I think the first part of the code assumes
a different data type than I am using.
I have a table (tblDocument), and a form (frmDocument)
based on the table. tblDocument contains fields [DocNum]
and [Revision]. The corresponding text boxes on
frmDocument are txtDocNum and txtRevision. I need a
message box to pop up if both fields match another
record. If DocNum 123, Revision A exists, a new record
can contain DocNum123 only if Revision is something other
than A. Both [DocNum] and [Revision] are text fields.
The code I have (which is wrong, but I wonder if I am even
close) is (underscore means no line break):
If DCount("*", "tblDocument", "txtDocNum = " &_
Me.DocNum & " AND txtRevision = ' " & Me.Revision_
& " ' ") > 0 Then
MsgBox ...
and the rest of the code is OK. I am pretty sure I need
some single quotes in the first part, since it is text,
but I can't find the combination that works. The trouble
is that I can't tell to which part of the expression the
quotes belong. The other trouble is that in VBA field
names, etc. are sometimes in brackets, sometimes in
quotes, and probably some other options as well. If there
is a pattern, I have not yet discovered it.