browse: forums | FAQ
Connecting Tech Pros Worldwide

Hey there! Do you need Microsoft Access / VBA help?

Get answers from our community of Microsoft Access / VBA experts on BYTES! It's free.

Copying data from field to field in form automatically ?

Andy Hutchings
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi everybody - hope you can help out here.

I have a form in a database, which is a columnar form from one of the tables
in the db - there is a sub-form to the form which is a datasheet view of
another table in the db. The LinkChilds property is set to show connected
records from both tables.

What I'd like to do is copy and paste, or use some other method of writing,
the contents of one field in one table in the form, to a field in the table
in the sub-form, preferably with a button on the form which will copy the
data without having to manually copy and paste from field to field.

Is this sort of thing possible ?, and could anybody maybe point me in the
right direction as to how it might be done.

Cheers, and thanks in advance.

Andy

A N D R E W H U T C H I N G S , N E W C A S T L E UK
e-mail: andy@airnorth.demon.co.uk



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003





DFS
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Copying data from field to field in form automatically ?


Andy,

Put the main form in design mode, drop a command button on it, and add some
code like this to the button's OnClick property (it will copy from the main
form to the subform):

me.subFormName.Form.Field1Name = me.Field1Name
me.subFormName.Form.Field2Name = me.Field2Name
....



"Andy Hutchings" <andy@airnorth.demon.co.uk> wrote in message
news:bqo8ms$lre$1$8302bc10@news.demon.co.uk...[color=blue]
> Hi everybody - hope you can help out here.
>
> I have a form in a database, which is a columnar form from one of the[/color]
tables[color=blue]
> in the db - there is a sub-form to the form which is a datasheet view of
> another table in the db. The LinkChilds property is set to show connected
> records from both tables.
>
> What I'd like to do is copy and paste, or use some other method of[/color]
writing,[color=blue]
> the contents of one field in one table in the form, to a field in the[/color]
table[color=blue]
> in the sub-form, preferably with a button on the form which will copy the
> data without having to manually copy and paste from field to field.
>
> Is this sort of thing possible ?, and could anybody maybe point me in the
> right direction as to how it might be done.
>
> Cheers, and thanks in advance.
>
> Andy
>
> A N D R E W H U T C H I N G S , N E W C A S T L E UK
> e-mail: andy@airnorth.demon.co.uk
>
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003
>
>[/color]


Andy Hutchings
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Copying data from field to field in form automatically ?


Thanks very much for the prompt reply - I have tried it, but I don't think
I'm writing the code correctly.

I'm not sure what 'me' is ..... could you re-write the code with my db names
etc. in their correct place, as per the following names please.

Database name = Civil
Form name = Changes (same name as underlying table)
sub-form name = bbH (same name as underlying table)
Field name in Changes = NAME
Field name in bbH = OWNER

I want the field NAME in Changes to be written to the field OWNER in bbH

Sorry if I'm totally thick, and thanks again

Andy

"DFS" <nospamDS@nospam.com> wrote in message
news:vsvads1hq4dq6e@corp.supernews.com...[color=blue]
> Andy,
>
> Put the main form in design mode, drop a command button on it, and add[/color]
some[color=blue]
> code like this to the button's OnClick property (it will copy from the[/color]
main[color=blue]
> form to the subform):
>
> me.subFormName.Form.Field1Name = me.Field1Name
> me.subFormName.Form.Field2Name = me.Field2Name
> ...
>
>
>
> "Andy Hutchings" <andy@airnorth.demon.co.uk> wrote in message
> news:bqo8ms$lre$1$8302bc10@news.demon.co.uk...[color=green]
> > Hi everybody - hope you can help out here.
> >
> > I have a form in a database, which is a columnar form from one of the[/color]
> tables[color=green]
> > in the db - there is a sub-form to the form which is a datasheet view of
> > another table in the db. The LinkChilds property is set to show[/color][/color]
connected[color=blue][color=green]
> > records from both tables.
> >
> > What I'd like to do is copy and paste, or use some other method of[/color]
> writing,[color=green]
> > the contents of one field in one table in the form, to a field in the[/color]
> table[color=green]
> > in the sub-form, preferably with a button on the form which will copy[/color][/color]
the[color=blue][color=green]
> > data without having to manually copy and paste from field to field.
> >
> > Is this sort of thing possible ?, and could anybody maybe point me in[/color][/color]
the[color=blue][color=green]
> > right direction as to how it might be done.
> >
> > Cheers, and thanks in advance.
> >
> > Andy
> >
> > A N D R E W H U T C H I N G S , N E W C A S T L E UK
> > e-mail: andy@airnorth.demon.co.uk
> >
> >
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003
> >
> >[/color]
>
>[/color]


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003


DFS
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Copying data from field to field in form automatically ?


"Andy Hutchings" <andy@airnorth.demon.co.uk> wrote in message
news:bqobpq$jqu$1$8300dec7@news.demon.co.uk...[color=blue]
> Thanks very much for the prompt reply - I have tried it, but I don't think
> I'm writing the code correctly.
>
> I'm not sure what 'me' is ..... could you re-write the code with my db[/color]
names[color=blue]
> etc. in their correct place, as per the following names please.
>
> Database name = Civil
> Form name = Changes (same name as underlying table)
> sub-form name = bbH (same name as underlying table)
> Field name in Changes = NAME
> Field name in bbH = OWNER
>
> I want the field NAME in Changes to be written to the field OWNER in bbH[/color]

Andy, for purposes of this particular line of code:

database name = Civil = not important
Form name = Changes = not important
sub-form name = bbH = important
Me = reference to form executing the code = imporant
Field name in Changes = NAME = important
Field name in bbH = OWNER = important


On form "Changes", add a click button and this code to it:

me.bbH.Form.OWNER = me.[NAME]

(note: I put Name in brackets because it's a common property of Access
objects. In general you shouldn't use NAME as a field name).





[color=blue]
> Sorry if I'm totally thick, and thanks again
>
> Andy
>
> "DFS" <nospamDS@nospam.com> wrote in message
> news:vsvads1hq4dq6e@corp.supernews.com...[color=green]
> > Andy,
> >
> > Put the main form in design mode, drop a command button on it, and add[/color]
> some[color=green]
> > code like this to the button's OnClick property (it will copy from the[/color]
> main[color=green]
> > form to the subform):
> >
> > me.subFormName.Form.Field1Name = me.Field1Name
> > me.subFormName.Form.Field2Name = me.Field2Name
> > ...
> >
> >
> >
> > "Andy Hutchings" <andy@airnorth.demon.co.uk> wrote in message
> > news:bqo8ms$lre$1$8302bc10@news.demon.co.uk...[color=darkred]
> > > Hi everybody - hope you can help out here.
> > >
> > > I have a form in a database, which is a columnar form from one of the[/color]
> > tables[color=darkred]
> > > in the db - there is a sub-form to the form which is a datasheet view[/color][/color][/color]
of[color=blue][color=green][color=darkred]
> > > another table in the db. The LinkChilds property is set to show[/color][/color]
> connected[color=green][color=darkred]
> > > records from both tables.
> > >
> > > What I'd like to do is copy and paste, or use some other method of[/color]
> > writing,[color=darkred]
> > > the contents of one field in one table in the form, to a field in the[/color]
> > table[color=darkred]
> > > in the sub-form, preferably with a button on the form which will copy[/color][/color]
> the[color=green][color=darkred]
> > > data without having to manually copy and paste from field to field.
> > >
> > > Is this sort of thing possible ?, and could anybody maybe point me in[/color][/color]
> the[color=green][color=darkred]
> > > right direction as to how it might be done.
> > >
> > > Cheers, and thanks in advance.
> > >
> > > Andy
> > >
> > > A N D R E W H U T C H I N G S , N E W C A S T L E UK
> > > e-mail: andy@airnorth.demon.co.uk
> > >
> > >
> > >
> > > ---
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003
> > >
> > >[/color]
> >
> >[/color]
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003
>
>[/color]


Andy Hutchings
Guest
 
Posts: n/a
#5: Nov 12 '05

re: Copying data from field to field in form automatically ?


Thank you again very much for confirming that code.

I have done as you said, but am now getting an error message "Microsoft
Access can't find the macro 'me'." when I click the button to try to execute
the operation. I'm using Access97 btw ...

Thank you very much

Andy
e-mail: andy@airnorth.demon.co.uk


"DFS" <nospamDS@nospam.com> wrote in message
news:vsvekr25p0gr43@corp.supernews.com...[color=blue]
> "Andy Hutchings" <andy@airnorth.demon.co.uk> wrote in message
> news:bqobpq$jqu$1$8300dec7@news.demon.co.uk...[color=green]
> > Thanks very much for the prompt reply - I have tried it, but I don't[/color][/color]
think[color=blue][color=green]
> > I'm writing the code correctly.
> >
> > I'm not sure what 'me' is ..... could you re-write the code with my db[/color]
> names[color=green]
> > etc. in their correct place, as per the following names please.
> >
> > Database name = Civil
> > Form name = Changes (same name as underlying table)
> > sub-form name = bbH (same name as underlying table)
> > Field name in Changes = NAME
> > Field name in bbH = OWNER
> >
> > I want the field NAME in Changes to be written to the field OWNER in bbH[/color]
>
> Andy, for purposes of this particular line of code:
>
> database name = Civil = not important
> Form name = Changes = not important
> sub-form name = bbH = important
> Me = reference to form executing the code = imporant
> Field name in Changes = NAME = important
> Field name in bbH = OWNER = important
>
>
> On form "Changes", add a click button and this code to it:
>
> me.bbH.Form.OWNER = me.[NAME]
>
> (note: I put Name in brackets because it's a common property of Access
> objects. In general you shouldn't use NAME as a field name).
>
>
>
>
>
>[color=green]
> > Sorry if I'm totally thick, and thanks again
> >
> > Andy
> >
> > "DFS" <nospamDS@nospam.com> wrote in message
> > news:vsvads1hq4dq6e@corp.supernews.com...[color=darkred]
> > > Andy,
> > >
> > > Put the main form in design mode, drop a command button on it, and add[/color]
> > some[color=darkred]
> > > code like this to the button's OnClick property (it will copy from the[/color]
> > main[color=darkred]
> > > form to the subform):
> > >
> > > me.subFormName.Form.Field1Name = me.Field1Name
> > > me.subFormName.Form.Field2Name = me.Field2Name
> > > ...
> > >
> > >
> > >
> > > "Andy Hutchings" <andy@airnorth.demon.co.uk> wrote in message
> > > news:bqo8ms$lre$1$8302bc10@news.demon.co.uk...
> > > > Hi everybody - hope you can help out here.
> > > >
> > > > I have a form in a database, which is a columnar form from one of[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > tables
> > > > in the db - there is a sub-form to the form which is a datasheet[/color][/color][/color]
view[color=blue]
> of[color=green][color=darkred]
> > > > another table in the db. The LinkChilds property is set to show[/color]
> > connected[color=darkred]
> > > > records from both tables.
> > > >
> > > > What I'd like to do is copy and paste, or use some other method of
> > > writing,
> > > > the contents of one field in one table in the form, to a field in[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > table
> > > > in the sub-form, preferably with a button on the form which will[/color][/color][/color]
copy[color=blue][color=green]
> > the[color=darkred]
> > > > data without having to manually copy and paste from field to field.
> > > >
> > > > Is this sort of thing possible ?, and could anybody maybe point me[/color][/color][/color]
in[color=blue][color=green]
> > the[color=darkred]
> > > > right direction as to how it might be done.
> > > >
> > > > Cheers, and thanks in advance.
> > > >
> > > > Andy
> > > >
> > > > A N D R E W H U T C H I N G S , N E W C A S T L E UK
> > > > e-mail: andy@airnorth.demon.co.uk
> > > >
> > > >
> > > >
> > > > ---
> > > > Outgoing mail is certified Virus Free.
> > > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > > Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003
> > > >
> > > >
> > >
> > >[/color]
> >
> >
> > ---
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003
> >
> >[/color]
>
>[/color]


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27/11/2003


Closed Thread