New record in Forms

chrisguk

Registered User.
Local time
Today, 02:01
Joined
Mar 9, 2011
Messages
148
I have a main form which pulls a unique ID called "pkSitesID"

I have placed a button on this form to open another form called "frmSitesLog" and link by fkSitesID and display only records that match the pkSitesID.

All that works perfect. The only issue I am having is when I want to insert a new record into the the "frmSitesLog" the SitesID field does not retain the link between the pkSitesID.

How to I get around this?
 
In frmSitesLog's On Load event you could use;
Code:
Me.pkSitesID.DefaultValue =  Me.pkSitesID
 
In frmSitesLog's On Load event you could use;
Code:
Me.pkSitesID.DefaultValue =  Me.pkSitesID


Hi John that didnt work and probably nothing to do with your advice. I didnt give all the correct info. So here it is:

Main form = frmSitesMain

pkSitesID
Other fields etc

On this form I have a cmd button that opens:

frmSitesAccounts

I have the following fields in this form:

fkSitesID
AccountID
AcctNo
dteAcctOpen
dteAcctClosed

I have a linktable between the two source tables called:

tblSitesLink:

SitesLinkID
NavID

Not sure if that makes any difference.

So when I open the frmSitesAccounts the fkSitesID is populated by the pkSitesID field value contained within frmSitesMain. This all works well enough until I want to add a new record in the frmSitesAccounts form. It does not retain the link between frmSitesMain and frmSitesAccounts.

Does that make sense?
 
Hi, from your forms, i would assume you have 2 tables, tblSitesMain and tblSitesAccounts. you said this:

I have a linktable between the two source tables called:

tblSitesLink:

SitesLinkID
NavID

Not sure if that makes any difference.

i don't think this makes a difference, but is your tblSitesMain and tblSitesAccounts linked in a relationship? they should be as you have fkSitesID in your frmSitesAccounts.

when you have a relationship, you can just create frmSitesAccounts as a subform in frmSitesMain. the fkSitesID will populate itself in this case.

however, if you need to have frmSitesAccounts as a mainform instead of a subform, you will need to do some VBA coding.

hope this has helped you.
 

Users who are viewing this thread

Back
Top Bottom