You could add an additional macro action -- FindRecord -- after your
message box (or before, whichever you prefer) that will let you move the
form to the appropriate record, based on the value of the unique key field
that was entered. This assumes that
-- you have not dirtied the current record (if you have, then I
don't believe a macro is going to be useful for you because it cannot
"undo" the dirtying of the record that will occur when the user first
types the value into the control); and
-- that your form's RecordSource contains all the records from the
table so that you can "find" that particular record in the form's
recordset data.
(I apologize for the delay in answering your question -- got tied up with
some other work...)
--
Ken Snell
<MS ACCESS MVP>
tankerman said:
I am using ACCESS 2003 and I used marco as you suggested
:
Are you using an ACCESS macro or VBA code?
--
Ken Snell
<MS ACCESS MVP>
Ken it works perfect once I got all of my textbox names corrected, I
was
able
to use this in several of my form just by changing the names. One of
my
forms
"EventsEntry" has a field "TicketID" which is the primary key in the
my
table
"Events". Instead of just stopping us from entering and giving us the
msgbox
(which is great) can we some how be directed to the record that has
the
same
"TicketeID" field so we can be update it and we don't have to go
looking
for
it. Every event transaction has it's own TicketID but when Tickets
are
brought in we don't know if it has been entered or not so your macro
stopped
us from that problem but now to find that "TicketID" and update. it.
Ken Snell (MVP)" wrote:
Aarrghh... error in my post -- corrected:
Actually this can be done with Macro and no VBA. Just need to put the
testing expression (DCount("*", "[NameOfTable]", "[BargeName] = '" &
[Textbox1] & "'") > 0) in the Condition column, and use CancelEvent
action
as the first action, and MsgBox as second action (with ellipsis in
Condition
column), and StopMacro as third action (with ellipsis in Condition
column).
--
Ken Snell
<MS ACCESS MVP>
message
Put logic in the BeforeUpdate event of the control into which
you're
typing the BargeName to check whether the name already appears.
While I know you're posting in the Macros group, I believe you're
going
to need to use VBA for this. Don't worry, it's not that difficult.
Actually this can be done with Macro and no VBA. Just need to put
the
testing expression (DCount("*", "[NameOfTable]", "[BargeName] = '"
&
Me.Textbox1 & "'") > 0) in the Condition column, and use
CancelEvent
action as the first action, and MsgBox as second action (with
ellipsis
in
Condition column), and StopMacro as third action (with ellipsis in
Condition column).