
Originally Posted by
June7
Why is same data in two tables?
Have to actually populate field, something like:
Me!AttachmentID = some value
Now the trick is figuring out how to get value to second form. Options:
1. First form code sets value of second form field
2. Second form sets its own field value by referencing control or field on first form
3. Pass value via OpenArgs argument of OpenForm
DoCmd.OpenForm "FormB", , , , , , Me!AttachmentID
Then code in second form:
If Me.NewRecord Then Me!AttachmentID = Me.OpenArgs
4. Should this actually be a form/subform arrangement?
Thank you so much for your reply. To answer your question, AttachmentID is actually the unique key in the table behind Form A. It is how I am linking the data in Form A to Form B.
The problem with a subform is it gets embedded in the master form. There's no way to make a popup subform as far as I know. The reason that's a problem is I would also need to create subforms for Form C, D, E, F, G, H and J. And all in Form A. So Form A is liable to get very cluttered if I make Forms B through J into subforms. I considered using the tabs option but I don't find it asthetically pleasing.
I tried option 3 as you suggested but I can't quite get it to work.
Here's the code I put into the command button on Form A.
Code:
Private Sub Command30_Click()
Me.Requery
DoCmd.OpenForm "FormB", , , , , , Me!AttachmentID
End Sub
And here's the code I put into Form B. (I figured it should be a Form Open function.)
Code:
Private Sub Form_Open(Cancel As Integer)
If Me.NewRecord Then Me!AttachmentID = Me.OpenArgs
End Sub
Form B opens, but the AttachmentID isn't populated. Should I try a different event procedure for the code in Form B?