By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,124 Members | 2,208 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,124 IT Pros & Developers. It's quick & easy.

Populate Subform field with Mainform field

P: 4
Hi there,

main form name = reserveringen
subform name = subform reserveringen
main form fields are: datetot, datevan, fietscode.
Subform fields are: dateuit, datemin, fietsid

Now i want to fill in data in the main form fields and populate the data into the subform fields after the fietsid is typed.
Because the data in 2 first to field is most of the time the same data for each record. Only the fietsid is every tim ea new uniek number.

How can i do this?

I tried this:
Private Sub fietscode_AfterUpdate()
Me!dateuit.Value = Me.Subform_reserveringen.Form.Datemuit.Value
Me!datein.Value = Me.Subform_reserveringen.Form.Datemin.Value
Me!fietscode.Value = Me.Subform_reserveringen.Form.FietsID.Value
End Sub

But i doesn't work

I work with access 2007

Anybody can help me?

If you like to have a copy of the database mail me

Thanks in advange
Dec 9 '07 #1
Share this Question
Share on Google+
7 Replies


puppydogbuddy
Expert 100+
P: 1,923
Hi there,

main form name = reserveringen
subform name = subform reserveringen
main form fields are: datetot, datevan, fietscode.
Subform fields are: dateuit, datemin, fietsid

Now i want to fill in data in the main form fields and populate the data into the subform fields after the fietsid is typed.
Because the data in 2 first to field is most of the time the same data for each record. Only the fietsid is every tim ea new uniek number.

How can i do this?

I tried this:
Private Sub fietscode_AfterUpdate()
Me!dateuit.Value = Me.Subform_reserveringen.Form.Datemuit.Value
Me!datein.Value = Me.Subform_reserveringen.Form.Datemin.Value
Me!fietscode.Value = Me.Subform_reserveringen.Form.FietsID.Value
End Sub

But i doesn't work

I work with access 2007

Anybody can help me?

If you like to have a copy of the database mail me

Thanks in advange
Try it as shown below, although I have questions about the control names used on the left hand side of the expression because you stated your main form fields are: datetot, datevan, fietscode, yet you are using different names with the exception of fietscode. If the names you used are not the names of the main form fields, replace Me!dateuit and Me!datein with the correct name of the main form fields as appropriate.
Expand|Select|Wrap|Line Numbers
  1. Private Sub fietscode_AfterUpdate()
  2. Me!dateuit = Me![subform reserveringen].Form!datemuit.Value
  3. Me!datein = Me![subform reserveringen].Form!datemin.Value
  4. Me!fietscode = Me![subform reserveringen].Form!fietsID.Value
  5. End Sub
Dec 9 '07 #2

P: 4
Hi,


Thank you for you help to get the correct syntax!

One question.

After 1 filled the last field (fietscode) and press enter i want have a new record in the subform with the data i filled in the fields on the main form.
How can i do this.

Sorry for my bad English and hope you understand the question.

I want to make it in the form that i only need to fill in the date from and the data till and that type multiple fietsid's.

Greetings and thanks,

Hendrik
Dec 10 '07 #3

puppydogbuddy
Expert 100+
P: 1,923
Hi,


Thank you for you help to get the correct syntax!

One question.

After 1 filled the last field (fietscode) and press enter i want have a new record in the subform with the data i filled in the fields on the main form.
How can i do this.

Sorry for my bad English and hope you understand the question.

I want to make it in the form that i only need to fill in the date from and the data till and that type multiple fietsid's.

Greetings and thanks,

Hendrik
Hendrik,
If you want to populate the subform from fields in the main form, it is just the opposite of what I gave you above.
Expand|Select|Wrap|Line Numbers
  1. Private Sub fietscode_AfterUpdate()
  2. Forms!reserveringen![subform reserveringen].Form!datemuit = Me!dateuit.Value
  3. Forms!reserveringen![subform reserveringen].Form!datemin = Me!datein.Value
  4. Forms!reserveringen![subform reserveringen].Form!fietsID = Me!fietscode.Value
  5. End Sub
Dec 11 '07 #4

P: 4
Hi,

I try to explain my problem better by giving a example.

When people come rent a bikes i ask them when do you return the bikes?
They give me a date. Now i know the startdate(today) and the day they return the bikes. For all the bikes are the rentingdate the same.
Now i only have to register the bikes they rent. Every bikenumber is typed in followed by the enter-key.

What i want to happen is when i type a bikenumber followed by enter-key in the subform a new record with the startdate, enddate en bikenumber.

I hope this explaining what i want.


Greetings Hendrik
Dec 11 '07 #5

puppydogbuddy
Expert 100+
P: 1,923
Hi,

I try to explain my problem better by giving a example.

When people come rent a bikes i ask them when do you return the bikes?
They give me a date. Now i know the startdate(today) and the day they return the bikes. For all the bikes are the rentingdate the same.
Now i only have to register the bikes they rent. Every bikenumber is typed in followed by the enter-key.

What i want to happen is when i type a bikenumber followed by enter-key in the subform a new record with the startdate, enddate en bikenumber.

I hope this explaining what i want.


Greetings Hendrik
Hendrik,
The syntax I gave you in my previous post should work, provided that you have established the master/child link in the subform control. that link is what makes the main form and subform function as if they were one...and the syntax I gave you in my prior post should autofill the fields indicated. If it is not working, please explain the details of what happens.
Dec 11 '07 #6

P: 4
Hi,

Thanks for your patience..

I have used the example of Nothernwind as the same structure as my database.
The master/child link is establish.
(Same as Orders / Orderinformation)

When i fill the fields with the begin and end-date en the bike number and press the enter-key the field i just filled become empty and nothing happens in the sub form. So nothing happens. The field with begin and end-date must be stay filled and the bike code must be empty after i filled in a bike number.
So i can type the next number.


Greetings Hendrik
Dec 12 '07 #7

puppydogbuddy
Expert 100+
P: 1,923
Hi,

Thanks for your patience..

I have used the example of Nothernwind as the same structure as my database.
The master/child link is establish.
(Same as Orders / Orderinformation)

When i fill the fields with the begin and end-date en the bike number and press the enter-key the field i just filled become empty and nothing happens in the sub form. So nothing happens. The field with begin and end-date must be stay filled and the bike code must be empty after i filled in a bike number.
So i can type the next number.


Greetings Hendrik
Hendrik,
The field becomes empty after you enter fietscode on the main form?

Before you enter fietscode, is the subform displayed?

Did you put the code (see below) I gave you behind the main form or behind the subform? Itshould be behind the main form.

If you go to the poperty sheet for the AfterUpdate event for fietscode, does it show the words "Event Procedure?

What fields do you have as your master and child links?
Expand|Select|Wrap|Line Numbers
  1. Private Sub fietscode_AfterUpdate()
  2. Forms!reserveringen![subform reserveringen].Form!datemuit = Me!dateuit.Value
  3. Forms!reserveringen![subform reserveringen].Form!datemin = Me!datein.Value
  4. Forms!reserveringen![subform reserveringen].Form!fietsID = Me!fietscode.Value
  5. End Sub
Dec 12 '07 #8

Post your reply

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