473,840 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connecting A Sub Form

Probably another easy question...

I have two data tables. One holds the main data, the other holds
additional data on a many-to-one relationship with the main data.
Using the forms wizard, my goal was to create a form where you enter
the main record, then a button brings up the sub-form where you enter
as many of the additional info records as needed, all linking back to
the main record.

However, the forms don't seem linked in that way. When the sub-form
comes up, the record being entered in no way refers back to the record
on the main form. So, of course, when I try to enter records into the
sub-form I get errors about the referential integrity.

I imagine that one way to solve this would be to, on the button that
shows the sub-form, first post the parent form's record and then pass
its primary key to the sub-form to use in its foreign key. How would
these two steps be accomplished in the code?

Or is there an easier/better way to do this?
-cyber0ne

Aug 13 '06 #1
3 2269
cyber0ne wrote:
Probably another easy question...

I have two data tables. One holds the main data, the other holds
additional data on a many-to-one relationship with the main data.
Using the forms wizard, my goal was to create a form where you enter
the main record, then a button brings up the sub-form where you enter
as many of the additional info records as needed, all linking back to
the main record.

However, the forms don't seem linked in that way. When the sub-form
comes up, the record being entered in no way refers back to the record
on the main form. So, of course, when I try to enter records into the
sub-form I get errors about the referential integrity.

I imagine that one way to solve this would be to, on the button that
shows the sub-form, first post the parent form's record and then pass
its primary key to the sub-form to use in its foreign key. How would
these two steps be accomplished in the code?

Or is there an easier/better way to do this?
-cyber0ne
What you have is not a subform. A subform is one that is embedded inside another
using a subform control. What you have is simply a separate form opened
pre-filtered to show records related to the record on the first form. As you
have seen that filter does nothing to provide linking on NEW records you might
enter. All it does is filter on existing records.

Using an actual subform would give you the behavior you want. Otherwise you
have to build into the forms you have additional stuff to provide the linking
for new records. If they are related on a single field then you can set the
default value property for the TextBox on the second form so that it references
the first form's linking field. That entry would look like...

=Forms!NameOfFo rm!NameOfField

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Aug 13 '06 #2
What you have is not a subform. A subform is one that is embedded inside another
using a subform control. What you have is simply a separate form opened
pre-filtered to show records related to the record on the first form. As you
have seen that filter does nothing to provide linking on NEW records you might
enter. All it does is filter on existing records.

Using an actual subform would give you the behavior you want. Otherwise you
have to build into the forms you have additional stuff to provide the linking
for new records. If they are related on a single field then you can set the
default value property for the TextBox on the second form so that it references
the first form's linking field. That entry would look like...
I got my terminologies crossed :) You are correct, though. Using the
sub-form option in the wizard gives me exactly the behavior I want.
Now I can customize it to my needs.

What I was trying to use was linked forms. Given my design, I'd prefer
the linked forms, though the sub-form model will do just fine if need
be. Is there a way to have a linked forms behave as such?
-cyber0ne

Aug 13 '06 #3
cyber0ne wrote:
What you have is not a subform. A subform is one that is embedded
inside another using a subform control. What you have is simply a
separate form opened pre-filtered to show records related to the
record on the first form. As you have seen that filter does
nothing to provide linking on NEW records you might enter. All it
does is filter on existing records.

Using an actual subform would give you the behavior you want.
Otherwise you have to build into the forms you have additional
stuff to provide the linking for new records. If they are related
on a single field then you can set the default value property for
the TextBox on the second form so that it references the first
form's linking field. That entry would look like...

I got my terminologies crossed :) You are correct, though. Using the
sub-form option in the wizard gives me exactly the behavior I want.
Now I can customize it to my needs.

What I was trying to use was linked forms. Given my design, I'd
prefer the linked forms, though the sub-form model will do just fine
if need be. Is there a way to have a linked forms behave as such?
-cyber0ne
Yes, in the second paragraph of my first post I explained how to do that. If
you want the "linked" form to automatically synch with the first form when you
change records on the first form then you would have to use code in the first
form's Current event.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Aug 13 '06 #4

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

Similar topics

4
1722
by: paul | last post by:
My first php script involves logining in to a site. I used a tutorial from a book and it doesn't seem to be working correctly. The code is below I started with a simple form to insert a username and password ------------------------------------------------ quote:<?php pass.form.php ?> <html>
1
1818
by: Tim Dol | last post by:
I have inherited a VB6-SP5 program connecting to an Access 2000 database. I'm relatively new to VB/Access programming, so I may overlook something obvious. I'll try to explain the problem I can't solve. My VB executable and Access database are both stored in a shared folder on a Novell volume. The first user has a good performance, but the second user has to wait 9 seconds to open the first form. The third user has to wait 18 seconds,...
4
3749
by: Sacha Korell | last post by:
First of all, sorry for cross-posting, but this newsgroup is much busier than "aspnet.mobile". I'm trying to create a portal page that redirects depending on the device that is connecting. When I use Request.Browser("IsMobileDevice"), it returns false when connecting with my iPAQ 2215 (and other Windows Mobile 2003 devices), although HTTPBrowserCapabilities "Platform" returns "WinCE".
12
2803
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed both the iis and sql server in a single machine. Not too long ago, the machine had some hardware problems, and management has decided to purchase new servers, for both asp.net and sql server.
5
2384
by: bill | last post by:
I am having difficulties connecting to a remote Sql server database in VB.net. Lets say my remote server is found at 255.255.255.255 and its name is MyServer. The database is called MyDatabase. I drap my SQLDataAdapter on to the form and set up a new connection at the wizard. I am putting the IP address of my server under server name and entering my login and password. I get an access denied. Sql Server Error: 17.
0
3076
by: NewsReader | last post by:
Hello, I have been looking around the net for a script to help me connect to and help gather information from Cisco routers/switches. I have pieced together a couple of different scripts from various different sources. I am having issue when connecting to Cisco devices. For some reason the scripts timesout/stops working just after the connection section of the script. It does not give me a confirmation of completeion nor does it give me...
29
7091
by: Bryce K. Nielsen | last post by:
Suddenly this week, I've started getting this error message: System.Data.SqlClient.SqlConnection(GetOpenConnection)ExecuteNonQuery requires an open and available Connection. The connection's current state is connecting. I'm very puzzled since I'm not calling "ExecuteNonQuery" and I am calling "Open", which I've always assumed was Synchronous, i.e. would not return until either A) the connection was open or B) there was an error. Here...
1
1406
by: roboesch | last post by:
I'm working on connecting information in 3 forms and trying to carry the heading over from the main form. On Form A there are links to form B and Form C, when you move to for B (or C) from A you are always returned to record 1 of each, which I'd like them to move to the applicable record (A12 to B12 for example) and have the item # (which is table A's primary key) autopopulate to forms B and C, any help?
1
1816
by: kinnu | last post by:
hi, could any one help me with the steps of connecting the vb form with the oracle database/table. I could connect vb to access. as my collage project requires connecting of vb with oracle database/table please help me with the steps. Thanks.
3
1597
by: akirekab | last post by:
I am tired, as I have done this or similar things many times, I am not seeing the problem here. I will run a query producing the following SQL SELECT tblInterviewRecord.FaceToFaceReasonID, tblInterviewRecord.InterviewtypeID, tblInterviewRecord.ContactDate, tblEmployees.Initials, tblInterviewRecord.ServiceTypeID, tblFaceToFaceReason.FaceToFaceReason FROM tblEmployees INNER JOIN (tblInterviewRecord INNER JOIN tblFaceToFaceReason ON...
0
9860
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9699
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10922
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10603
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10660
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7838
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7023
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
4076
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3138
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.