473,473 Members | 2,176 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Linking 2 forms

I have 2 forms - 'Existing Instructor' and 'New Course' which are
linked. The first form has the following fields - InstructorID,
Instructor First Name, Instructor Lase Name and Department, all of
which get populated when the form loads - the information for all the
fields is retrieved from an 'Instructor' table. The 'New Course' form
has 3 fields - InstructorID, CourseID, Course Name. If a user on the
'Existing Instructor' form clicks a button 'Add New Course'(named
Command11), it should open the 'New Course' form, displaying the
corresponding InstructorID but the other 2 fields should remain blank.
When the user enters information for CourseID & Course Name, and click
a button 'Add Course' on the form, the CourseID & Course Name are
inserted into another table 'Course'. The 'Instructor' table has a
one-to-many relationship with the 'Course' table.

Here's my problem. I have an idea of how to synchronize 2 forms' data
but I don't know how to fill only the 'InstructorID' field on the 'New
Course' form and leave all other fields blank and ready for data entry.
It's important that the InstructorID value in this form matches the
InstructorID value of the previous form 'Existing Instructor'. Right
now, when i click on the 'Add New Course' button on the 'Existing
Instructor' form, it opens the
'New Course' form with all the fields blank. I can manually enter the
values for InstructorID, CourseID & Course Name, and click button 'Add
Course' to add the data to the 'Course' table but I want the
'InstructorID' to be generated automatically. Please help.

Shal

Nov 13 '05 #1
6 1641
Shaldaman wrote:
I have 2 forms - 'Existing Instructor' and 'New Course' which are
linked. The first form has the following fields - InstructorID,
Instructor First Name, Instructor Lase Name and Department, all of
which get populated when the form loads - the information for all the
fields is retrieved from an 'Instructor' table. The 'New Course' form
has 3 fields - InstructorID, CourseID, Course Name. If a user on the
'Existing Instructor' form clicks a button 'Add New Course'(named
Command11), it should open the 'New Course' form, displaying the
corresponding InstructorID but the other 2 fields should remain blank.
When the user enters information for CourseID & Course Name, and click
a button 'Add Course' on the form, the CourseID & Course Name are
inserted into another table 'Course'. The 'Instructor' table has a
one-to-many relationship with the 'Course' table.

Here's my problem. I have an idea of how to synchronize 2 forms' data
but I don't know how to fill only the 'InstructorID' field on the 'New
Course' form and leave all other fields blank and ready for data entry.
It's important that the InstructorID value in this form matches the
InstructorID value of the previous form 'Existing Instructor'. Right
now, when i click on the 'Add New Course' button on the 'Existing
Instructor' form, it opens the
'New Course' form with all the fields blank. I can manually enter the
values for InstructorID, CourseID & Course Name, and click button 'Add
Course' to add the data to the 'Course' table but I want the
'InstructorID' to be generated automatically. Please help.

Shal

I'm not sure if this answers the question but you can pass an argument
to the next form
DoCmd.OpenForm "someform", , , , , , "ArgumentToPass"
or you could fill it in after the form
DoCmd.OpenForm "someform"
Forms!SomeForm!InstructorID = 123
if the form you open is not modal.
Nov 13 '05 #2
That was a really good idea - I went ahead and set the subform's
OnCurrent property to show the same InstructorID as the main form using
your idea. It works but my only problem is that the other fields are
getting populated from the Course table. I want those fields to be
associated with the Course table because on clicking the Add Course
button, the values from those should get inserted into the table(i.e. i
don't want the fields to be unbound or i won't be able to insert values
into the table). I've got that working(the insertion into the table
part)but i don't want the values from the Course table to be pulled up
each time the form opens. Otherwise, users will overwrite exisiting
values.

If a user with InstructorID value 72 opens the New Course form, this is
how it should look:
InstructorID = 72 (Only this field should be filled)
CourseID = ---------
Course Name = -----------

What do I do? By the way, thanks for the earlier tip.

Nov 13 '05 #3
I think I might have figured it out. I passed blank values for the
other fields:

Private Sub Form_Current()
Me!InstructorID = Forms![Existing Instructor]!InstructorID
Me!CourseID = ""
Me!CourseName = ""
End Sub

This seems to work. Thanks.

Nov 13 '05 #4
Shaldaman wrote:
I think I might have figured it out. I passed blank values for the
other fields:

Private Sub Form_Current()
Me!InstructorID = Forms![Existing Instructor]!InstructorID
Me!CourseID = ""
Me!CourseName = ""
End Sub

This seems to work. Thanks.

In the Docmd.OpenForm you can also open it so it is in Add mode
docmd.OpenForm "x",,,,acFormAdd
so you could open it and then populate the InstructorID
Nov 13 '05 #5
I didn't think about that. Let me give that a shot. I have another
quick question - I'd done this before but for some reason I can't
remember how to do it. How do I make the InstructorID text field
non-editable? Thanks again...

Nov 13 '05 #6
Shaldaman wrote:
I didn't think about that. Let me give that a shot. I have another
quick question - I'd done this before but for some reason I can't
remember how to do it. How do I make the InstructorID text field
non-editable? Thanks again...

Well, I'd open the properties form and set locked to True
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting...
3
by: John South | last post by:
I have an Access 2000 front end that I wish to work with a SQL Server 2000 database by means of Linked tables. Do I have to use an ODBC connection to SQL Server? It seems to be the only option...
14
by: diskoduro | last post by:
Hi!! Years ago I built a database to control the production of a little factory. The users wanted to work in a Windows Net workgroup so I created an mdb with all the tables and data an after...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
2
by: Mike Boozer | last post by:
I have two subforms on my main form. I want the records on subform B to correspond with the records on subform A which they do. However, I want the records on subform A to let me know if there is a...
1
by: santociabattari | last post by:
Hi Folks, I have 3 forms I want to link, so that when I advance 1 record in one form it will update the other two with the same record in the first form. I have tried using the form wizard (I...
1
by: MJ | last post by:
I have a database where, when I put 3 forms on one form they link fine and auto fill in information as they should; however, when I try to use the Tab Control form I am having trouble having to...
2
by: danthrom | last post by:
Hi all, I am trying to hid a command button which links two forms. The forms are connected by a one-to-many relationship and the second form has details on the first. But if no details are...
3
by: Robert McEuen | last post by:
Using A2K3, Windows XP I'm handling a many-to-many relationship with a linking table structure as follows (irrelevant fields omitted): tblIssue PK_IssueID (autonumber, primary key) IssueName...
0
by: Tarik Monem | last post by:
I have been working on an all AJAX/DOM web site which is set to go live today and I thought I'd share my discoveries with all of you whom have helped me when I have encountered different issues along...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.