473,412 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Controlling New Record on a Sub-Form

4 Nibble
I have an invoice form to capture invoice date, customer information and other information pertinent to the invoice. It has a sub form that captures the line items of the invoice. The table tblInvoice stores the invoice information and tblInvoiceDetail captures the line item. The sub-form is not visible until all the needed invoice fields are entered. When I make the sub-form visible, the fields for the first item are displayed. As soon as I tab out of the first field on the sub-form, a second record line, preceded by an asterisk, is displayed below the active detail record. How can I control this new record line from appearing until I want it to.
Dec 28 '20 #1
10 2669
NeoPa
32,556 Expert Mod 16PB
Forms have a Property called AllowAdditions. If this is set to No then that asterisk (*) line, which is the place-holder for entering new records, won't show. This can be set in Design View or by VBA code.
Dec 28 '20 #2
RickRock
4 Nibble
How do I get another record for more line items? Should I put a button on the sub-form?
Dec 28 '20 #3
NeoPa
32,556 Expert Mod 16PB
RickRock:
How do I get another record for more line items?
I have no idea what you're trying to ask for. Give me some context. Something that would make clear what you're saying.
Dec 28 '20 #4
twinnyfo
3,653 Expert Mod 2GB
Rick,

It looks like you have your subform displaying as a datasheet--which is possible with a Subform, but not my recommended method. Create your subform so that you have controls for all your table fields and set its display property to continuous forms (try to line up all your controls horizontally). By itself, you should be able to view all line items for all invoices.

When on the main form, make sure you have the parent child relationship set on the subform to the invoice ID--or whatever primary key you are using for your invoices table.

Now, any time you add any line items, they will be associated with the Invoice ID of the main form.

Hope this hepps!
Dec 28 '20 #5
RickRock
4 Nibble
Yes this did help. Thank you.
Dec 29 '20 #6
cactusdata
214 Expert 128KB
How do I get another record for more line items? Should I put a button on the sub-form?

Yes, or on the main form. Let the button click event call:

Expand|Select|Wrap|Line Numbers
  1. Me!NameOfInvoiceLinesSubformCONTROL.Form.AllowAdditions = True
In the AfterInsert event of the subform call:

Expand|Select|Wrap|Line Numbers
  1. Me.AllowAdditions = False
Dec 29 '20 #7
twinnyfo
3,653 Expert Mod 2GB
All,

Would it not be more simple to have AllowAdditions set to true on the subform in the first place? After all, it is a form designed to "add records". I see no need to keep switching back and forth between true and false. You can also control what data is required (both at Table or Form level) so that you don't add incomplete records.

I'm open to learning about any advantages of turning this switch on and off.
Dec 29 '20 #8
NeoPa
32,556 Expert Mod 16PB
TwinnyFo:
I'm open to learning about any advantages of turning this switch on and off.
The requirement is simply the request of the OP Twinny. If they ask for something, and I don't suspect it leads them in a bad direction, I'm generally happy simply to answer.

Where I see indication of the question arising from a poor understanding I may add some explanation as I feel it's our responsibility to help rather than simply answer questions, but where I have no idea why they may ask for something I generally just answer.

TwinnyFo:
After all, it is a form designed to "add records".
I'm not sure it is quite as simple as that. A Subform can be used to add records but it is always used to display them. Sometimes the ability or right to add records has to be triggered by some qualification or other. Sometimes in the data, sometimes by the user.
Dec 29 '20 #9
twinnyfo
3,653 Expert Mod 2GB
Neo,

Your second paragraph makes much sense. If the Form were merely for display, we would not expect AllowAdditions to be true. The user entering data would need that functionality, and they could either initiate that function (as described above), or, if the DB was designed in such a way as to know "who" logged in, this feature could be set automagically.

Sometimes I forget to look at things from that "other perspective". As usual, I appreciate the reminder!
Dec 29 '20 #10
NeoPa
32,556 Expert Mod 16PB
TwinnyFo:
Sometimes I forget to look at things from that "other perspective". As usual, I appreciate the reminder!
I find it so much harder nowadays because I'm actually using Access as a coded Front-End. When I first started here I was using it pretty much for data only and some menu forms. All the more complicated work to answer questions in here was done by simply looking things up in Help and running some dummy scenarios to find answers to questions. As I had no experience then there was nothing to tell me how things should work and so I had very few assumptions. Nowadays I'm far more inclined to assume it all works the way it does in my actual projects so I can certainly sympathise.

At the end of the day we live & learn. Hopefully I can remember back to when I knew how much I didn't know ;-)
Dec 29 '20 #11

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

Similar topics

2
by: chrisM | last post by:
Hi, Hope someone can help me. I have the following setup in an Access database A master form 'Customers' in 'Single Form' view that has a RecordSource of 'myCustomerTable' CustomerCode...
4
by: Craig M | last post by:
Hi, I have 2 forms, frmretailorders, and frmretailorderline. in the oncurrent of the main form, I check what the value of !status is. If it is "complete", then i disable all text and combo...
8
by: anansi | last post by:
Hi I have a form called 'shiftviewer' and it contains a subform called 'all shifts for current month subform'. the subform is in datasheet view (access 2007) and the main form is a column...
1
by: andyb7901 | last post by:
Hey, I have a combo box based on a table. It has two columns; The key which is hidden and the name of a location. On the form there is a subform which has a number of fields for equipment. This is...
6
by: dk4300 | last post by:
Hi!! I have a subform with a comments (memo) field, linked to a form. On the Memo field: Properties-Other-Enter Key Behavior = New Line in Field On the subform: Properties- Other- Cycle =...
0
by: Andrew | last post by:
Hi all A quick question which I've not been able to solve from trawling the web. Is it possible to have a control in the detail section of a form set to a default view of "Continuous" which...
1
by: Chipperzs | last post by:
All, First time user, I tried searching for related posts but none pertaining to my specific problem. I have a form with a "Continuous" subform on it. The Continuous subform has a combo box...
8
by: PotatoChip | last post by:
I have a form which shows information about our controlled documents. I also have a subform which tells you everything about the many places this document was distributed to. So, Form 1234 would have...
0
by: Gordon Padwick | last post by:
A form contains controls, one or more of which can be other forms. A form that contains another form is known as a main form. A form contained by a main form is known as a subform. A subform itself...
0
by: benkelly89 | last post by:
Hi To give a bit of background this is an asset register for all assets and pat testing database in one. Two tables concerned are asset register and risk assessments. The reason the tables are...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
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,...
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...

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.