get value from form field

G

Guest

Hi, Thanks for your help in the past. I have a main form and subform which
are now working OK (thanks). I have a second subform (which has no
master/child link because it is not related to the main form but only to the
first subform). I want this second subform to automatically receive the value
of a field from the selected record in the first subform. How do I do this?
Do I use an Event, query or code?

The first subform displays one or more student records. The primary key is
StudentId. When I select the record I want to go to the subform (which is the
data entry form) and have the StudentId retrieved from the first subform. The
tables are linked thru the field StudentId. At the moment this second subform
works Ok but the user has to manually type in the StudentId which appears on
the first subform.
Any suggestions would be gratefully received. (I have almost no experience
with Access or VBA but am learning).
 
K

kingston via AccessMonster.com

Consider making the second subform a subform of the first subform. Since the
second subform is directly related to the first subform and not the main form,
it would work just like the main form and original subform. Create copies of
your forms and redesign the first subform by adding and linking the second
subform. If it doesn't work out, revert to your original design.

What is the purpose of the second subform? Is it simply for reference or
will it be used for data entry? At this point, if all you want to do is put
a value in the form, a default value might work:

[Forms]![MainForm]![SubForm1]![StudentID]
 
G

Guest

Hi Thanks for that. I think you are right. The second subform should be a
subform of the first subform. I have done and checked that master/child links
exist. The second subform is intended for data entry (StudentId, CourseId,
RSVPDate).

The first subform is based on a table StudentDetails with the primary key
StudentId. The second subform is based on a table CourseParticipants with the
primary key being two fields - StudentID and CourseId. Table StudentDetails
has a one to many relationship to CourseParticipants - with StudentId as the
link field.

However, when I select a record from the first subform and the second
subform pops up there are no fields to allow data entry - only field
headings. I can push tab many times and nothing is happening. I assume that
the tab keeps moving to fields which I can't see on the second subform. This
happens whether I set Data Entry to either Yes or No in the second subform
property. However, If a record exists in the table underlying the second
subform (CourseParticipants) this record will display if I set the second
subform to Data Entry No.

How can I get the second subform to allow new data entry into the
CourseParticpants table? I might add that when I have the second subform on
the main form, and not nested within the first subform and not linked to
either the main form or first subform, the data entry works fine. But then I
have the problem of not being able to select the record in the first subform
for data entry into the second subform. Any ideas what I am doing wrong?

Sorry, I didn't know where to put the default value in the second subform as
you suggested because the option for a default value doesn't appear.
Many thanks
--
Chrissy


kingston via AccessMonster.com said:
Consider making the second subform a subform of the first subform. Since the
second subform is directly related to the first subform and not the main form,
it would work just like the main form and original subform. Create copies of
your forms and redesign the first subform by adding and linking the second
subform. If it doesn't work out, revert to your original design.

What is the purpose of the second subform? Is it simply for reference or
will it be used for data entry? At this point, if all you want to do is put
a value in the form, a default value might work:

[Forms]![MainForm]![SubForm1]![StudentID]
Hi, Thanks for your help in the past. I have a main form and subform which
are now working OK (thanks). I have a second subform (which has no
master/child link because it is not related to the main form but only to the
first subform). I want this second subform to automatically receive the value
of a field from the selected record in the first subform. How do I do this?
Do I use an Event, query or code?

The first subform displays one or more student records. The primary key is
StudentId. When I select the record I want to go to the subform (which is the
data entry form) and have the StudentId retrieved from the first subform. The
tables are linked thru the field StudentId. At the moment this second subform
works Ok but the user has to manually type in the StudentId which appears on
the first subform.
Any suggestions would be gratefully received. (I have almost no experience
with Access or VBA but am learning).
 
K

kingston via AccessMonster.com

Let's say you have the following forms: FormA, FormB, and FormC. FormA is
the main form. FormB is the subform to FormA. FormC is the subform to FormB.


The first thing I suggest you do is create FormC and make sure it works
independently (i.e. not as a subform). Second, create FormB, check that it
works, and then add FormC as a subform. Now FormB/C should work properly as
a combination and data entry should work as expected (FormA doesn't even
exist at this point). Finally, create FormA, check that it works, and then
add FormB/C as a subform.

The main point is that the lowest form-subform combination should be created
first and function independently prior to adding it to the higher level.
Hi Thanks for that. I think you are right. The second subform should be a
subform of the first subform. I have done and checked that master/child links
exist. The second subform is intended for data entry (StudentId, CourseId,
RSVPDate).

The first subform is based on a table StudentDetails with the primary key
StudentId. The second subform is based on a table CourseParticipants with the
primary key being two fields - StudentID and CourseId. Table StudentDetails
has a one to many relationship to CourseParticipants - with StudentId as the
link field.

However, when I select a record from the first subform and the second
subform pops up there are no fields to allow data entry - only field
headings. I can push tab many times and nothing is happening. I assume that
the tab keeps moving to fields which I can't see on the second subform. This
happens whether I set Data Entry to either Yes or No in the second subform
property. However, If a record exists in the table underlying the second
subform (CourseParticipants) this record will display if I set the second
subform to Data Entry No.

How can I get the second subform to allow new data entry into the
CourseParticpants table? I might add that when I have the second subform on
the main form, and not nested within the first subform and not linked to
either the main form or first subform, the data entry works fine. But then I
have the problem of not being able to select the record in the first subform
for data entry into the second subform. Any ideas what I am doing wrong?

Sorry, I didn't know where to put the default value in the second subform as
you suggested because the option for a default value doesn't appear.
Many thanks
Consider making the second subform a subform of the first subform. Since the
second subform is directly related to the first subform and not the main form,
[quoted text clipped - 23 lines]
 
G

Guest

Thanks so much Kingston. I had designed the forms top down and started to
build them that way too. Much better idea to build them bottom up. I had been
going around in circles. You made me re-focus. Thanks so much for your very
sound advice.
--
Chrissy


kingston via AccessMonster.com said:
Let's say you have the following forms: FormA, FormB, and FormC. FormA is
the main form. FormB is the subform to FormA. FormC is the subform to FormB.


The first thing I suggest you do is create FormC and make sure it works
independently (i.e. not as a subform). Second, create FormB, check that it
works, and then add FormC as a subform. Now FormB/C should work properly as
a combination and data entry should work as expected (FormA doesn't even
exist at this point). Finally, create FormA, check that it works, and then
add FormB/C as a subform.

The main point is that the lowest form-subform combination should be created
first and function independently prior to adding it to the higher level.
Hi Thanks for that. I think you are right. The second subform should be a
subform of the first subform. I have done and checked that master/child links
exist. The second subform is intended for data entry (StudentId, CourseId,
RSVPDate).

The first subform is based on a table StudentDetails with the primary key
StudentId. The second subform is based on a table CourseParticipants with the
primary key being two fields - StudentID and CourseId. Table StudentDetails
has a one to many relationship to CourseParticipants - with StudentId as the
link field.

However, when I select a record from the first subform and the second
subform pops up there are no fields to allow data entry - only field
headings. I can push tab many times and nothing is happening. I assume that
the tab keeps moving to fields which I can't see on the second subform. This
happens whether I set Data Entry to either Yes or No in the second subform
property. However, If a record exists in the table underlying the second
subform (CourseParticipants) this record will display if I set the second
subform to Data Entry No.

How can I get the second subform to allow new data entry into the
CourseParticpants table? I might add that when I have the second subform on
the main form, and not nested within the first subform and not linked to
either the main form or first subform, the data entry works fine. But then I
have the problem of not being able to select the record in the first subform
for data entry into the second subform. Any ideas what I am doing wrong?

Sorry, I didn't know where to put the default value in the second subform as
you suggested because the option for a default value doesn't appear.
Many thanks
Consider making the second subform a subform of the first subform. Since the
second subform is directly related to the first subform and not the main form,
[quoted text clipped - 23 lines]
Any suggestions would be gratefully received. (I have almost no experience
with Access or VBA but am learning).
 

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