Primary Key Issue Between Forms

G

GrandMaMa

I have two forms in which to update data.

The first form where I enter four fields. Date, Last Name, High School and
Region

With a Command button I call a second tab format form.

Three fields make up the Primary Key.

Date, Last Name from FormA and District ID from form B.

I have used this approach to help eliminate errors, as this has to do with
expense accounts for the district.

I have tried to store the Date and Last Name to insert into the proper
fields of the records I am creating using form B. How can I do this so I do
not have to re-enter the Date and Last name on each record?

Been struggeling with this for four days! I have used the Control Source
Property to point to Form A and that does not work. I have moved it using
VBA and that fails also.

I just cannot populate the field quick enough to make Access happy!

Appreciate the help in advance

Granny
 
R

Rick Brandt

GrandMaMa said:
I have two forms in which to update data.

The first form where I enter four fields. Date, Last Name, High
School and Region

With a Command button I call a second tab format form.

Three fields make up the Primary Key.

Date, Last Name from FormA and District ID from form B.

I have used this approach to help eliminate errors, as this has to do
with expense accounts for the district.

I have tried to store the Date and Last Name to insert into the proper
fields of the records I am creating using form B. How can I do this
so I do not have to re-enter the Date and Last name on each record?

Been struggeling with this for four days! I have used the Control
Source Property to point to Form A and that does not work. I have
moved it using VBA and that fails also.

I just cannot populate the field quick enough to make Access happy!

Appreciate the help in advance

Granny

Set the DefaultValue property of those control on FormB to references to
FormA.

=Forms!FormA!FieldName
 
G

GrandMaMa

Rick;

Thanks for getting back to me.

FormB is in Tabular Format. I have already tried what you suggested,
and I get a Message that the Primary Key cannot contain a Null Value after
the last field on the line.

For some reason is does not populate the field fast enough in the
record. When I do a Debug or MsgBox the Contents are there! For some reason
the Field in the record never gets what I am seeing in debugging the program.

Any other ideas?
 
R

Rick Brandt

GrandMaMa said:
Rick;

Thanks for getting back to me.

FormB is in Tabular Format. I have already tried what you
suggested, and I get a Message that the Primary Key cannot contain a
Null Value after the last field on the line.

For some reason is does not populate the field fast enough in
the record. When I do a Debug or MsgBox the Contents are there! For
some reason the Field in the record never gets what I am seeing in
debugging the program.

Any other ideas?

Let's clarify the situation. You have FormA open and FormB is not. In
design view of FormB you have entered as DefaultValue properties of...

=Forms!FormA!FieldName

....for both of the controls where the value needs to carry over from FormA
to FormB. When you pres the button on FormA that opens FormB you should be
able to scroll to the new record position and see that the default values
are populated with the values in FormA before you do any sort of entry on
FormB. If you have the linking fields hidden on FormB you will need to
temporarily show them to do this test.

Are you saying that those default values are NOT being displayed or that you
still get a Null error anyway?
 
G

GrandMaMa

Rick;

Again, thanks. I Started from skratch a very small two form DB.
FormA and FormB. I open FormB on a Command Button.

My Record has four fields, Date, District, First Name and Last Name.

I entered the Date into FormA, Opened Form B and went to insert the
first Employee Name. When I tried to move to the Last Name from the First
Name Field I get a "Index or Primary Key cannot contain a Null Value"
Message.

FormA = ExpDate

FormB Control is = Forms!FormA!ExpDate

Thanks Again

Granny
 
R

Rick Brandt

GrandMaMa said:
Rick;

Again, thanks. I Started from skratch a very small two form DB.
FormA and FormB. I open FormB on a Command Button.

My Record has four fields, Date, District, First Name and Last
Name.
I entered the Date into FormA,

Okay, first off you need to make sure that the record on FormA is aved
before you open FormB In the code for the butotn use...

Me.Dirty = False
DoCmd.OpenForm blah blah...
Opened Form B and went to insert
the first Employee Name. When I tried to move to the Last Name from
the First Name Field I get a "Index or Primary Key cannot contain a
Null Value" Message.

FormA = ExpDate

FormB Control is = Forms!FormA!ExpDate

Where do you have Forms!FormA!ExpDate enterd on FormB? It should be in the
DefaultValue property. NOT in the ControlSource property.
 

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

Top