473,413 Members | 2,066 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,413 software developers and data experts.

Add Row(s) to my subform based on Combobox selection

Hi,

I have a subform (datasheet view) on my Mainform, where a user can enter information. I need help on how to display the required number of rows in my subform based on the number selected in the dropdown box on my mainform. Please see the attached GIF. for example if a user selects 5 from the dropdown then automatcially the subform below should display 5 rows for entering data, with a default value of "UNKNOWN" in each column.
many thanks if someone can help me here.
Attached Images
File Type: jpg subform.jpg (8.0 KB, 643 views)
May 25 '09 #1
12 5032
FishVal
2,653 Expert 2GB
I guess this stuff could be used for it. However it will require some effort from you to adapt the concept to your application.

Regards,
Fish
May 25 '09 #2
Thks Fish.

I am not an expert on VBA or access. So would need your help here.
I just want to add rows to my subform when I select some number from the combobox on my main form. By default we have 1 row of record to add data to in the subform, but i want to display the rows based on my combobox selection.
Thxs again.
May 25 '09 #3
NeoPa
32,556 Expert Mod 16PB
You'll need to provide more information before you can expect any sort of step-by-step help here. This question is missing most of the required info.

As an aside, why is this done as a subform? Are you aware that forms can have header and footer sections?
May 25 '09 #4
FishVal
2,653 Expert 2GB
@kashif73
Well. I have a version adapted for your application. Unfortunately attachments are not working currently. So I'll post it later.
May 25 '09 #5
Hi NeoPa,

Sorry couldn't explain it better. firstly i am not aware of footer & header sections on a FORM. Would appreciate your help on it.

Here's what I am trying to do. I am capturing info on violation of human rights done in some areas in my database & then I also capture information in a sub form on person(s) like there religion, ethnicity & age, who were abused.

I have a main form called ADD EVENT, where i enter details of violations. This info goes to TABLE 1.

Then in my sub form , PERS INFO, I enter the personnel details of those people who were abused. This subform saves info in TABLE 2. I save this info in a seperate table since there could be more than 1 person, whose info can be entered for a particular violation. Both tables are linked to each other.

I just want to add rows to my subform when I select some number from the combobox on my main form. By default we have 1 row of record to add data to in the subform, but i want to display the rows based on my combobox selection.
May 25 '09 #6
Thxs Fish. I'll be waiting.
May 25 '09 #7
FishVal
2,653 Expert 2GB
@kashif73
Ok. Looks like problem with Attachment was actualy a browser problem.
  • The following based on assumption that your main form / subform are feeded by 2 tables with 1-to-many relationship.
  • To use the method you need to add an auxiliary table which holds a set of sequential natural numbers [1,2,3, ... N]. BTW, the same table could be advantageously used as your combobox rowsource.
  • The table on the "many" side has to get an additional field which stores a row ordinal in rowset rendered in subform. The aim of the field is certainly not to persist row ordinal (though, depending on your requirements, it may be a desired feature) but to produce an updateable query to feed subform.
  • There is some code behind the forms to mimick main form / subform interface since Access native master/child relation is disabled.
Attached Files
File Type: zip AddRows.zip (20.1 KB, 262 views)
May 25 '09 #8
NeoPa
32,556 Expert Mod 16PB
@kashif73
This posts adds a lot of the info missing from the original :)
@kashif73
From what you've since added, I guess it is not appropriate, but when viewing a form in Design mode you can select to show or hide the Header/Footer from the View menu.
@kashif73
How?

Please provide table details - including fields and link info.
@kashif73
Are you sure?

This seems to me like a problem waiting to happen (Adding records without info is likely to be a problem. How much of one is hard to say without the Metadata info).

Why not have the items entered as you add new ones? You could include code to restrict it to the number selected if you wish.
May 25 '09 #9
@FishVal
Dear Fish,

Many thanks for your help. This is exactly what I was looking for. Awesome.
best regards,
May 26 '09 #10
The following based on assumption that your main form / subform are feeded by 2 tables with 1-to-many relationship.
To use the method you need to add an auxiliary table which holds a set of sequential natural numbers [1,2,3, ... N]. BTW, the same table could be advantageously used as your combobox rowsource.
The table on the "many" side has to get an additional field which stores a row ordinal in rowset rendered in subform. The aim of the field is certainly not to persist row ordinal (though, depending on your requirements, it may be a desired feature) but to produce an updateable query to feed subform.
There is some code behind the forms to mimick main form / subform interface since Access native master/child relation is disabled.
Hi Fish, Reference your solution (AddRows.zip). Can there be a way that I can display UNKNOWN as default value in the field 'txtchild'. for example if I select 8 from the combo box, then in my frmChild I should get 8 rows(which I am getting) but with UNKNOWN as default value for txtchild.

I have tried to set UNKNOWN as default value in the field properties but it isn't working. Likewise also tried in the AfterUpdate event of cmbNN but didnt work.
Thanks.
May 31 '09 #11
FishVal
2,653 Expert 2GB
Hi, Kashif.

The provided solution is not suited for this.

Kind regards,
Fish.
Jun 1 '09 #12
so can there be another way of doing it? any hint?
Jun 1 '09 #13

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

Similar topics

1
by: Alvey Sidecast | last post by:
This is probably embarrassingly simple, but I've been trawling through this ng for hours now and my brain hurts. I've got an unbound multi-column listbox (multi-select=none) whose rowsource is a...
3
by: Nicolae Fieraru | last post by:
Hi All, I have a problem and I can't figure out how to solve it. My database has three tables: tblCustomers, with CustomerId and CustomerName tblProducts, with ProductId and ProductCode...
1
by: Trent | last post by:
I am in the design phase of a new database and am having a devil of a time with a subform. I have three tables that relate to problem - Suppliers tbl, Customers tbl and a SuppliersCustomers tbl....
3
by: PeterZ | last post by:
G'day, After doing much searching and pinching bits of ideas from here there and everywhere I came up with a fairly 'clean' solution of including a comboBox into a dataGrid column. You can...
3
by: Christopher Weaver | last post by:
I want to set a value in a specific field in the current row of a DataSet. This seems like the most basic thing to do but I can't find the syntax for identifying the current row. IOW, I can do...
18
by: Robert Jacobs | last post by:
Please advise... I currently have a Mainform (Customers) and a Subform (Service Requests) with a one to many relationship (one customer, many service requests) with a CustomerID that is unique...
13
by: BASSPU03 | last post by:
Hello, folks. This is my first post and I only began to work extensively with Access about 3 weeks ago. I'm running Access 2003 on Windows XP. I'd like a textbox in subform2 to reflect the value...
2
by: billypit | last post by:
Hi, I have one form in which I have one combobox and one subform. now when I am selecting value from combobox it will show details in subform by filtering from table based on my selection of...
1
by: Rosie | last post by:
I have a main form with header info w/ 'tHeader' as the control source. I have a subform with 'tDetail' as a control source. They're strung together by a field named MA_ID. This works...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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...

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.