Auto-populate fields

  • Thread starter Thread starter fathi_abuayyash via AccessMonster.com
  • Start date Start date
F

fathi_abuayyash via AccessMonster.com

Hello,

I have command button in the master form, i would like to write code to copy
the data from field1 to field2 in the subform, consider that i have many
records in the sub form.

i wrote this code
[Form]![TBL_Invoice Details subform2]![Approved Amount] = [Form]![TBL_Invoice
Details subform2]![Billed Amount]


but this will execute only for the first line, how i can make it loop for the
rest and copy the data from field1 to field2 in the sub form?

any help?
 
Hello,

I have command button in the master form, i would like to write code to copy
the data from field1 to field2 in the subform, consider that i have many
records in the sub form.

i wrote this code
[Form]![TBL_Invoice Details subform2]![Approved Amount] = [Form]![TBL_Invoice
Details subform2]![Billed Amount]


but this will execute only for the first line, how i can make it loop for the
rest and copy the data from field1 to field2 in the sub form?

any help?

You're not updating data in a Subform. Subforms don't CONTAIN data - they just
*display* it! The data exists in a Table, and only in the Table.

What you'll need to do is to run an Update query on the subform's recordsource
table, using appropriate criteria to update only those records pertaining to
the currently displayed record.


John W. Vinson [MVP]
 
Hello,
i am trying to copy data from one field to another on the display form. then
the user can change the data if needed then press save to update with the new
changes,
is there any way?


[quoted text clipped - 10 lines]
any help?

You're not updating data in a Subform. Subforms don't CONTAIN data - they just
*display* it! The data exists in a Table, and only in the Table.

What you'll need to do is to run an Update query on the subform's recordsource
table, using appropriate criteria to update only those records pertaining to
the currently displayed record.

John W. Vinson [MVP]
 
i am trying to copy data from one field to another on the display form. then
the user can change the data if needed then press save to update with the new
changes,
is there any way?

That seems to contradict what you say in the initial message: that you want to
copy the value into *multiple* records on the subform.

If that's what you want to do, then my advice stands. You cannot have multiple
subform records open simultaneously - only one. To have the same value visible
in multiple records (on the subform), they must be stored in that subform's
table.

John W. Vinson [MVP]
 
Hello John,

Thanks for your reply,
to make my self more clear,
i have a field a and field b

the form has many rows, i just want to copy the values from one text box to
another,
it does not matter if i stored it in db or not, i just want to press the
button and copy from a to b.

i appreciate if you can help, if not maybe some one has idea of how this can
be done on the form level.

cheers
 
i did this code

Do
[Approved Amount] = [Billed Amount]
DoCmd.GoToRecord , , acNext
Loop


it worked perfect, but endlessly :) i need now to find how to find the actual
row count in the form to add the condition for the do statment to stop after
last record.
 
Yurika,

DoCmd.GoToRecord , , acFirst {go always to first
record}
Do
[Approved Amount] = [Billed Amount]
DoCmd.GoToRecord , , acNext {after populating the
field then go to next record}
If [Billed Amount] = 0 Then {check if the
value for next field}
Exit Do
Else
End If
Loop


but if any one has better way to do it , please write it down.

i want to know how i can find the record counts in the form?


Thanks
 
Back
Top