ACCESS 2003: Checking to see if record exists BEFORE UPDATE and then display message THEN OPEN existing record -
ACCESS 2003: Checking to see if record exists BEFORE UPDATE and then display message THEN OPEN existing record -
working on awhile , i'm getting runtime error 2501
i'm trying pull record after message box appears stating duplicate has been found , upon clicking "ok" pulls record.
i have been tinkering docmd.findrecord, docmd.gotorecord, , docmd.openform methods no avail.
any help appreciated.
thanks in advance.
private sub mrn_beforeupdate(cancel integer) dim reply variant reply = dlookup("[mrn]", "requests processed", "[mrn] = '" & me.mrn & "'") if not isnull(answer) msgbox "existing mrn found" & ": " & mrn.text & vbcrlf & vbcrlf & "please search , edit on existing record.", vbcritical + vbokonly + vbdefaultbutton1, "existing mrn found" cancel = true me.mrn.undo else: end if docmd.openform "requests processed", , , reply end sub
from help topic, openform
method's wherecondition alternative "a string look that's valid sql clause without word where."
try openform
way ...
docmd.openform "requests processed", , , "[mrn] = '" & reply & "'"
it looks me work. seems can utilize same string both dlookup
criteria alternative , openform
wherecondition. if that's true create 1 string variable (eg strwhere) , utilize in both places.
ms-access-2003
Comments
Post a Comment