openForm new record problem

  • Thread starter Thread starter Rohan via AccessMonster.com
  • Start date Start date
R

Rohan via AccessMonster.com

Hello.

I have a label on Form A with an onClick method that opens a new form (form B)
with the following code:

stDocName = "frmdocument_review_referral"

MsgBox "doc_review_id = " & Me![doc_review_id]
stLinkCriteria = "[doc_review_id]=" & Me![doc_review_id]
DoCmd.OpenForm stDocName, , , stLinkCriteria

The Form B works if the record exists in the database.. How do I create a
new record using the doc_review_id of form A when the record for Form B
doesn't exist.

Rohan.
 
It's ok - I did it by using the default value of the doc_review_id on form B
to be set to the doc_review_id
value on form A.

Ta,

Rohan.
 
in your code, add and If condition so if the doc_review_id is null then you
open the form with no criteria, and then use. docmd.gotorecord like
docmd.GoToRecord acActiveDataObject,,acNewRec

the condition code can be like:

if isnull(me.doc_review_id) = true then
stDocName = "frmdocument_review_referral"

MsgBox "doc_review_id = BLANK"
DoCmd.OpenForm stDocName
docmd.GoToRecord acActiveDataObject,,acNewRec
else
"your normal code"
end if
 
Back
Top