Linking 2 forms

M

myxmaster

I have a command button on a form called accounts that opens a form
called memo. The memo form is a data entry form. I have a field on the
memo form named customerid, and also a field on the accounts form
called customerid. I am stumped as to how to link the memo form with
the accounts form. When I enter a memo it is not associated with any
account.. I have found if I place the memo form on the accounts form
and enter a memo it is associated with the correct account. Any help
is most appreciated as I am sure it is something simple in linking the
2 forms together.
TIA
 
A

Arvin Meyer [MVP]

The easiest way that I have found is to open the memo form with a where
clause:

Sub cmdOpen_Click()
DoCmd.OpenForm "Memo",,,,"customerid=" & Me.customerid
End Sub

On the memo form set the DefaultValue of the customerid textbox to:

=Forms!FirstFormName!customerid

Now, if there is a matching record it opens to that record, if not, it
creates one with an id equal to the one on the calling form.
 
M

myxmaster

The easiest way that I have found is to open the memo form with a where
clause:

Sub cmdOpen_Click()
DoCmd.OpenForm "Memo",,,,"customerid=" & Me.customerid
End Sub

On the memo form set the DefaultValue of the customerid textbox to:

=Forms!FirstFormName!customerid

Now, if there is a matching record it opens to that record, if not, it
creates one with an id equal to the one on the calling form.
--
Arvin Meyer, MCP, MVPhttp://www.datastrat.comhttp://www.mvps.org/accesshttp://www.accessmvp.com






- Show quoted text -

Hi Arvin,
I have tried your advise however I keep getting a Type Mismatch
error. Also do I replace first form name with the name of the actual
form "Accounts"?
 
A

Arvin Meyer [MVP]

Hi Arvin,
I have tried your advise however I keep getting a Type Mismatch
error. Also do I replace first form name with the name of the actual
form "Accounts"?

If your customerid is a text datatype, that will happen. If so, try:

DoCmd.OpenForm "Memo",,,"customerid=" & "'" & Me.customerid & "'"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top