Simple syntax error, I'm sure

Kraj

Registered User.
Local time
Today, 12:02
Joined
Aug 20, 2001
Messages
1,470
Hey folks. I've got what I'm sure is a simple syntax error but I can't seem to find similar code to what I want in the forums and finding correct syntax references in MS help files is nearly impossible, so here I am.

I need to pass the value of a field on one form to another. This is my code:

Forms!subfrmRecipientSelect!PackageID = Forms!frmPackageContents!PackageID

I would think this is correct syntax since I also have:

Forms!frmPackageContents!subfrmDocuments_In_Package.Form.Requery

which works just fine. Nevertheless I get the error "Microsoft Access can't find the form..." Apparently no one has posted this error message before because it doesn't come up on a forum search. I know the spelling of the form names are correct. I've tried variations using brackets and quotes, etc. with no success. Can anyone see what I'm doing wrong?
 
Kraj,

If you are trying to populate the key value for the subform (and you're
not using the Master-Child links) then just set the default value for
the subform's PackageID to: Forms![frmPackageContents]![PackageID].

That should work. If it doesn't work, you've probably got the form
name right, but PackageID is probably really named something like
Text12 or something.

Wayne
 
Nope and Nope. I can't set the default to PackageID from the Package Contents form because that form isn't open at the time, nor is the new package record created yet. Both fields also are correctly named PackageID, but the error message says it can't find the form, not the field. Thanks for trying!

Edit: Got it! I had forgotten when referencing a subform you must first reference the main form it's on. The corrected version of my code is:

Forms!frmMailing.Form!subfrmRecipientSelect.Form!PackageID = _
Forms!frmPackageContents!PackageID
 
Last edited:

Users who are viewing this thread

Back
Top Bottom