473,725 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding records through Subform

36 New Member
I've got myself a bit mixed up with all my sqls and subforms. I am a bit new to relationship databases.

I have a database designed for booking students on to courses run at our hospice. It is based on three main tables. [tblCourselist], [tblStudentinfor mation] and a table to link these [tbleLINKStudent _Course].

I have a form [frmStudentCours eRecord] based on [tblStudentinfor mation] with a subform based on an SQL query which i have listed below. This shows the details of the course(s) the student is registered on or have been on previously:

Expand|Select|Wrap|Line Numbers
  1. SELECT tblLINKStudent_Course.lngStudentID, tblLINKStudent_Course.lngCourseID, tblLINKStudent_Course.Courseattended, tblLINKStudent_Course.CoursePaid, tblLINKStudent_Course.CourseComplete, tblLINKStudent_Course.Heardaboutcourse, tblLINKStudent_Course.CourseInfoSent, tblLINKStudent_Course.MemNotes, tblLINKStudent_Course.DateBooked, tblLINKStudent_Course.BookedBy, tblCourselist.lngCourseID, tblCourselist.strCourseTitle, tblCourselist.curCourseCost, tblCourselist.strLunchProvided, tblCourselist.memNotes, tblCourselist.CourseDate, tblLINKStudent_Course.PaidBy, tblLINKStudent_Course.strDietryRequ, tblLINKStudent_Course.[Booking Reference]
  2. FROM tblCourselist INNER JOIN tblLINKStudent_Course ON tblCourselist.lngCourseID = tblLINKStudent_Course.lngCourseID
  3. ORDER BY tblLINKStudent_Course.DateBooked DESC;
Not sure if this is the best way to display the code.

THE PROBLEM:

I want to be able to enrole a student on a new course so that once registered, the details will be recorded on the subform, which is based on my sql query, for that individual. The table [tblCourseList] contains all the courses run at the hospice, with all the relevant fields [curCourseCost] etc.

WHAT I HAVE TRIED:
I have placed a control button in the subform with a macro to open a new form which is a copy of the subform, remaned as [frmAddCourseFor Student] so it is stll based on the sql query above. I thought changing the field [strCourseTitle] to a combobox would allow me to select the right course and bobs your uncle. My mistake! The control source for this field is set as [tblCourseList] so i removed this and set the record source as a sql query [tblCourseList]SELECT [strCourseTitle]. This brings up list of courses in the field but nothing else.

I want to be able to select the course in this form, which then populates all the other linked fields like [curCourseCost] from [tblCourseList] so that when form [frmStudentCours eRecord] is opened for an individual student it will show all the courses enroled in in the subform with the newley added course.

Sorry for the long winded explanation but can anybody help me untangle my SQLs forms?

Thanks
Oct 29 '07 #1
11 1968
NeoPa
32,569 Recognized Expert Moderator MVP
You have (accidentally) posted this question in the Access Articles section. This is NOT an article.
I'm moving this to the main Access questions forum.

ADMIN.
Oct 29 '07 #2
NeoPa
32,569 Recognized Expert Moderator MVP
I'm not too hot on using forms like this, but (Example Filtering on a Form.) may help you from what I understand of your needs.
PS when posting code, the easy way to do it is to select all your code in a chunk, then click on the hash (#) button. This will add the code tags for you :)
Oct 29 '07 #3
CrostonScottish
36 New Member
Thanks for that. I have had a look at the code but will need some time to understand it.

Thanks
Oct 29 '07 #4
NeoPa
32,569 Recognized Expert Moderator MVP
Take your time.
This is a really useful concept once you get it :)
Oct 29 '07 #5
CrostonScottish
36 New Member
I have had a good look at the Form Filtering databased which is zipped on this thread. I have very little knowledge of VBA but could the code be cut down so that it filtered on just one control, e .g. CourseTitle but then place the returned values from the filter in a new form as a new record? If so, how

Not sure that explains my question very well. Would a copy of the database help to see where my question is coming from?
Nov 5 '07 #6
NeoPa
32,569 Recognized Expert Moderator MVP
I found your other post and was working on it when you reposted it in here. Quite funny really :D
I deleted all remnants of it now so we can continue in here as if it never happened.
Nov 5 '07 #7
NeoPa
32,569 Recognized Expert Moderator MVP
I have had a good look at the Form Filtering databased which is zipped on this thread. I have very little knowledge of VBA but could the code be cut down so that it filtered on just one control, e .g. CourseTitle but then place the returned values from the filter in a new form as a new record? If so, how

Not sure that explains my question very well. Would a copy of the database help to see where my question is coming from?
In answer to your question, No.
Some of the principles may be the same but you're asking about a separate aspect here really.

Filtering simply selects, from the available records, those that match a particular criteria. It does not set defaults for the controls on a form for when you add a new record. In other words - A filtered form will NOT restrict addition of new records to the filtered criteria.

This can be done, but with some extra code in your form to set defaults on the fly to those matching your criteria. Make sure to set the Control defaults rather than trying to change the defaults for the underlying Field in the table.
Nov 5 '07 #8
CrostonScottish
36 New Member
A shame nothing in life is quite so simple.
When you say a little extra code, what are we talking? For a complete novice like myself could you point me in the right direction with the code or do you have any sample code i could tweak?

Cheers
Nov 5 '07 #9
NeoPa
32,569 Recognized Expert Moderator MVP
Let me see if I can dig something up for you.
I don't know where it is at the moment but I'll see what I can find. Hopefully it's a work database that I did this on.
Nov 6 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
10186
by: Dee | last post by:
I have a form which contains basics of a customer's order from table . I placed a tab control on this form which is still empty. I'm trying to design a project management database and would like to enter one form for each sub project on each tab page. ...=>
1
4262
by: Andante.in.Blue | last post by:
Hi everyone! In Access 97, I have a parent form and a subform that are both based on the same query. The main form is continuous and serves up a summary for each record. The subform provides details on the record and is linked to the parent record via an autonumber ID. My users want to be able to add new records to the table underlying the main query (the query is structured so that new records can be added via its database view). I...
6
2505
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new products). Tables: tblCategoryDetails CategoryID SpecID
6
9857
by: Wendy Powley | last post by:
I have a subform which represents a 1:N relationship with the main form. I would like to be able to read values from an external file, fill the subform with the values read & allow the user to view/edit the values via the subform. I thought this would be accomplished using a simple loop; read values, assign the various fields of the subform & repeat for each row of the subform. Seems this is not possible, or at least I have been unable...
7
2012
by: Ron | last post by:
Hi All, Using Access2000, winXP. Table 1 = tblClients displayed on frmClients via qryClients. 2nd table = tblInvoices shown on frmInvoices via qryInvoices. 2nd table = tblDetails shown on subform(to frmInvoices) sfrmDetails via qryDetails. Relationship built between tblClients/tblInvoices/tblDetails by ClientID. Relationship between tblInvoices/tblDetails by InvoiceID. All works fine if
3
5350
by: john | last post by:
In my form (table A) I have subform (table B (only 2 fieds: ID and App_name) where table A -Table B are linked 1XM. To be able to add a record in the subform I want to use a lookup form since the number of possible values is over 300. For data consistancy I've locked the subform so that the user can't add or change values manually without using the lookup form. My question is: What's the best way of adding the record to table B which the...
0
1431
by: vljones | last post by:
Hoping to find a way of entering new data into a combo box which contains a list of items contained in a table. In addition I want to allocate an ID number to entries that are not currently in the list. I have Form with a subform - frmQuotation!frmSubLimits On the subform I have the following fields: txtSubLimit and numSubLimitID
0
1937
by: Richnep | last post by:
Hi all,. I have a small issue I would like to resolve with VBA. I have a form which it's fields are bound to a table. Within that form is a subform which is a subtable. Tables relationship is a one to many from the main table to the sub table.
2
2510
by: altesse33 | last post by:
I have a command button on the main form of my database that allows users to add new records. But, even though new records get added to the sub table when I click on the button, those new records aren’t immediately reflected in the combo box that is on the subform (whose record source is a junction table). Do you know of any methods I can add in an event procedure to update the subform? I added the following code based on a suggestion I...
3
1606
by: ramprat | last post by:
Hi All, I am using Access 2003 and have a continuous form based on a table (table1) as a subform on another form. I simply want to be able to take any records that get added to table1 through the subform and populate a 2nd table (table2) with these added records from the subform the instant they are added. The two tables both contain a common ID field. Also if any values in existing records on the subform change I would like to update a...
0
8889
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
8752
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
9401
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...
1
9179
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,...
0
8099
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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
6011
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();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.