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

Home Posts Topics Members FAQ

Can't create new record in subform

dee
I have a main form "FmLeads".
It contains a field "Salesman" which has an 'After Change' Event
Procedure.

The Main form "FmLeads", contains a subform "FmDispoHistory". It
displays all historic Salesman changes in continuous form format.

It is related to with ONE "FmLeads" record -->MANY "FmDispoHistory"
records via an ID field.

I need the Salesman 'After Change' Event Procedure on the main form to
add a new record to the "FmDispoHistory" subform, and then to assign
the value of the "Salesman" field from the main form to the "Salesman"
field in the subform.

Could someone help me with a few lines of VB code that can do tjhis?
Thank You

Dec 22 '06 #1
1 2214
On 21 Dec 2006 17:37:02 -0800, "dee"
<pr******************@comcast.netwrote:

You probably mean the AfterUpdate event.

Your db design probably includes at least 3 tables: Leads, Salesreps,
and SalesRepsOnLeads (LeadID, SalesrepID). We call this a many-to-many
relationship. Draw the relations in the relationship window and
enforce them. The SalesRepsOnLeads table is the one to insert a row
into.

You can do this without code. Make the subform's recordsource
SalesRepsOnLeads. Now you have 2 columns with numbers. Hide the LeadID
(this is the LinkChildFields). Then replace the SalesRepID with a
dropdown (RowSource = query like this: select SalesRepID, SalesRepName
from Salesreps), and keep the ControlSource as SalesRepID.

Then you can just go to a new line in the subform, drop down the
salesrep list, and select the new guy. Access will automatically
insert a new row in tblSalesrepsOnLeads.

This is a very powerful technique and the default way to handle
many-to-many situations. Only deviate from this if you REALLY know
what you're doing, and why. The Northwind sample application's Orders
form is another example of this implementation (M:M between orders and
products via orderdetails)

-Tom.

>I have a main form "FmLeads".
It contains a field "Salesman" which has an 'After Change' Event
Procedure.

The Main form "FmLeads", contains a subform "FmDispoHistory". It
displays all historic Salesman changes in continuous form format.

It is related to with ONE "FmLeads" record -->MANY "FmDispoHistory"
records via an ID field.

I need the Salesman 'After Change' Event Procedure on the main form to
add a new record to the "FmDispoHistory" subform, and then to assign
the value of the "Salesman" field from the main form to the "Salesman"
field in the subform.

Could someone help me with a few lines of VB code that can do tjhis?
Thank You
Dec 22 '06 #2

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

Similar topics

4
65586
by: YFS DBA | last post by:
How do I use VBA to insert a *new* record into a subform? I have a master form with client information, and a sub form with billing information. I want to click on a button ("Add Data") and have...
6
1625
by: B Blue | last post by:
here's the situation: a produce dept at a grocery store needs to generate a weekly sheet for ordering. This is how it looks: 5 columns across with the following headings: Product Description,...
5
1625
by: Galina | last post by:
Hello A have an application in MS Access 2000. It has a form (courses), which has a subform (course occurrences), which has a subform (occurrence learning aims). The Learning aims subform is...
1
680
by: sixsoccer | last post by:
I have built a database with a <Mainform> and a <Subform>. My problem is twofold. 1. My subform is set as a continuos form with AllowAddiotions set to NO (ie. a list of Issues to the client on...
2
2948
by: Deano | last post by:
Thanks for the replies to my previous post. So while I'm on a roll here's another plea for help. I simply need the code for a button on the main form that will create a new record in the...
1
2664
by: kkrizl | last post by:
I have a form that displays general information about an alarm permit location. There's a subform that shows detailed information about burglar alarms that have gone off at the location. When a...
4
2200
by: sparks | last post by:
I am trying to fix a database that someone did about 4 yrs ago in access97. The main table just contains demographics and is on the main form of the database. It has a subform on a tab that...
4
12410
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
4
1923
by: banderson | last post by:
Hello, I am having a problem getting a new record in a subform to append to the underlying table. When I add a new record to the main form, the subform is blank, except for the ID field, which is...
0
7052
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
7092
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
6744
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
6981
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...
1
4790
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
4488
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
1304
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
565
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
188
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.