473,569 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Autofilling a subform field

Hi,

I have a subform in a main form.
When I create new records in the subform I would like the Subform.
[Issue Ref] to autofill with the MainForm.[Ref]
It sounds quite simple, but ive been bustin my brains trying to get it
to work with no success.
The LinkChild / Master fields seem to be set up correctly, as only the
subform records for that particular Ref are being shown.
Link Child Field = Issue Ref
Link Master Field = Ref

I just cant get the Subforms Issue Ref to autofill.
Any ideas?
Cheers
Zieshan
Jul 10 '08 #1
5 1782
z.******@gmail. com wrote:
Hi,

I have a subform in a main form.
When I create new records in the subform I would like the Subform.
[Issue Ref] to autofill with the MainForm.[Ref]
It sounds quite simple, but ive been bustin my brains trying to get it
to work with no success.
The LinkChild / Master fields seem to be set up correctly, as only the
subform records for that particular Ref are being shown.
Link Child Field = Issue Ref
Link Master Field = Ref

I just cant get the Subforms Issue Ref to autofill.
Any ideas?
Cheers
Zieshan
Would entering something in the OnCurrent event of the subform similar to
If Me.NewRecord Then Me.Ref = Forms!MainFormN ame!Ref
work?
Bomfunk
http://www.youtube.com/watch?v=ZH6CYeXioR8
Jul 10 '08 #2
Smashed it - that works!! Nice one cheers for that.

I dont suppose you would know a way to insert the current date
automatically in the Date field?
Jul 10 '08 #3
Actually, it has worked, but has just chucked out a problem.
Whenever I try and create a new record using the new form I get the
error
"You cannot add or change a record because a related record is
required in table ......"
Even though I can create a record, it keeps chucking out this alert.

Would you know what the problem is?

Jul 10 '08 #4
z.******@gmail. com wrote:
Smashed it - that works!! Nice one cheers for that.

I dont suppose you would know a way to insert the current date
automatically in the Date field?
There's many ways to do that. Here's two simple ways of doing that.
They only affect new records.

I open a table in design mode with a field called DF. In the
DefaultValue row I entered
Now()
Any record created will use that default value which can be overwritten

In the control's property sheet of the form you could enter
=Now()
in the DefaultValue property.

If you don't want the time, use Date().

Here's a code way, in the OnCurrent event of a form.
If IsNull(Me.DateF ieldName) then Me.DateFieldNam e = Now()
This will affect both new and existing records.

IF you do use Now() just one caveat. Let's say you want records between
Date1 and Date2.
Where Date Between Date1 and Date2

For some reason you don't get any records for date2. Why? Because
using Date(), the time is midnight. So any records for Date2 with a
time not midnight will not be included. So you need to add a day to
date 2.
Where Date Between Date1 and Date2 + 1
This is only used if the date field is a date with time field.

Ahora Es
http://www.youtube.com/watch?v=3p1P4oYbmbU
Jul 10 '08 #5
z.******@gmail. com wrote:
Actually, it has worked, but has just chucked out a problem.
Whenever I try and create a new record using the new form I get the
error
"You cannot add or change a record because a related record is
required in table ......"
Even though I can create a record, it keeps chucking out this alert.

Would you know what the problem is?
Is the link between the main form and subform Ref? If so, the subform's
Ref value will be the value of the main form's Ref value so there is no
need to do what I suggested. Removed the code and let Access to the work.

Personally, I use AutoNumbers as my primary key. Then when I link to
the tables it's automatically assicated with a computer generated key.
Autonumbers used as keys may have sequence gaps but you don't care about
that if used as a key.

If that is not the problem let us know.
Jul 10 '08 #6

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

Similar topics

15
24787
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that contains the subform is named Clients. I have this code in the Add Client btn: If Forms!Clients.subformVisits!VisitDirty = True Then MsgBox "Visit...
2
5346
by: ivan | last post by:
I have a form (CustomerImfo) that has a subform within it (order). Within that subform is another subform (OrderDetail). That subform (OrderDetail) is displayed in Datasheet view. When I am entering customers and their respective orders, the first order entered is fine with the "tab" field orders correct. On the second and subsequent orders,...
25
10184
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab...
4
6985
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the user enters the last qualifying field on the main form. In one case this works fine, the subform shows the data the user wants to update -- which...
5
5239
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test box that is populated with the code =subfrm_media_review_sec_party.Form!first_name & " " & subfrm_media_review_sec_party.Form!last_name It...
1
3207
by: bcreighton | last post by:
I have created a bound subform on an unbound masterform linked together with a common field (A store's identification number) using an unbound combobox on the masterform and an invisible field on the subquery, which filters for a particular store. The subform is in continuous mode. So, what you see when you select a store is a list of all...
9
9674
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a master-child link to the first subform. subform2 - Master Field: subTrainingModule.Form!TrainingModuleTopicSK Child Field: TrainingModuleTopicSK
18
2152
by: DNK2007 | last post by:
Hi all, How to do autofilling of a web form in firefox using javascript. ie through java script program should do autofilling of the web form. Thanks DNK2007
9
1628
by: Ledmark | last post by:
Hello - I've made a form with a subform of the same table, which is for Dr's notes. On the subform I have the query sorting in decending order and a criteria to enter a patient's name so the last note written for that patient shows on the subform. How can I make it so that when a patient's name is entered for the subquery, that name...
0
7701
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...
0
7924
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. ...
0
8130
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...
1
7677
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...
0
7979
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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...
1
2115
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 we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
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...

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.