A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Get data from previous records



 
 
Thread Tools Display Modes
  #1  
Old February 8th, 2008, 01:56 AM posted to microsoft.public.access.forms
crtopher
external usenet poster
 
Posts: 42
Default Get data from previous records

once i have started entering data into a new record via a form (ie the record
is already created) i would like to go to another record, pinch some data
from some of the fields in that record and go back to the record i was just
on, & put that data in the equivalent fields. The data i would need to pinch
would be the same each each time (ie i don't need to select each time what
fields to import).

i can already go to the record i need to by means of a search combo box on
my form, but i don't know the way to copy the data and take it back to the
other record.

I am very basic with access....i can make forms and can edit the VBA behind
it a bit!!

Please be kind

Cheers
Chris
  #2  
Old February 8th, 2008, 02:27 AM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default Get data from previous records

Sounds like you want to set the Default Value for several of the controls on
your form, based on the data in a previous record.

You could add a command button to the form, and use it to set the
DefaultValue property of the control that had focus before you clicked the
button, i.e. Screen.PreviousControl. Then choose another control, and click
the button again to set that one, and so on.

DefaultValue is a string type, so you may need to add quotes around numeric
or date values to get the result you expect.

Also, add error handling in case PreviousControl does not resolve to
something with a value (e.g. another command button, or there was none.)

Here's an example of setting DefaultValue:
http://www.mvps.org/access/forms/frm0012.htm

Here's another alternative, that automatically carries data forward from the
last record, though that's not what you asked for
http://allenbrowne.com/ser-24.html

Note that these do not survive closing the form, unless you store the value
in a table in Form_Unload, and assign them again in Form_Load.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"crtopher" wrote in message
...
once i have started entering data into a new record via a form (ie the
record
is already created) i would like to go to another record, pinch some data
from some of the fields in that record and go back to the record i was
just
on, & put that data in the equivalent fields. The data i would need to
pinch
would be the same each each time (ie i don't need to select each time what
fields to import).

i can already go to the record i need to by means of a search combo box on
my form, but i don't know the way to copy the data and take it back to the
other record.

I am very basic with access....i can make forms and can edit the VBA
behind
it a bit!!

Please be kind

Cheers
Chris


  #3  
Old February 8th, 2008, 02:32 AM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Get data from previous records

On Thu, 7 Feb 2008 17:56:01 -0800, crtopher
wrote:

once i have started entering data into a new record via a form (ie the record
is already created) i would like to go to another record, pinch some data
from some of the fields in that record and go back to the record i was just
on, & put that data in the equivalent fields. The data i would need to pinch
would be the same each each time (ie i don't need to select each time what
fields to import).


It's not quite clear if this is what you mean, but you can set the default
value of a field in the AfterUpdate event of the form, so that the field will
be "sticky" - each time you enter a new record it will offer you the value
from the previous record as a default (which can be changed and become the new
default).

If you're trying to pinch PART of a field, that's harder, and it really
suggests that your table design may not be optimum. What is the nature of the
data and what would be carried over?

John W. Vinson [MVP]
  #4  
Old February 8th, 2008, 03:47 AM posted to microsoft.public.access.forms
crtopher
external usenet poster
 
Posts: 42
Default Get data from previous records

Thankyou John and Allen.

My problem is that i am editing an existing record and need to go to another
record to get the data (and i need the whole field not just part) then go
back to the record i was just editing and paste the data....the problem, as i
understand it, is that by setting the default value, that only works when you
go to a new record...the default value won't come across to an existing
record, the feilds of which may, or may not, already have data in them.



"John W. Vinson" wrote:

On Thu, 7 Feb 2008 17:56:01 -0800, crtopher
wrote:

once i have started entering data into a new record via a form (ie the record
is already created) i would like to go to another record, pinch some data
from some of the fields in that record and go back to the record i was just
on, & put that data in the equivalent fields. The data i would need to pinch
would be the same each each time (ie i don't need to select each time what
fields to import).


It's not quite clear if this is what you mean, but you can set the default
value of a field in the AfterUpdate event of the form, so that the field will
be "sticky" - each time you enter a new record it will offer you the value
from the previous record as a default (which can be changed and become the new
default).

If you're trying to pinch PART of a field, that's harder, and it really
suggests that your table design may not be optimum. What is the nature of the
data and what would be carried over?

John W. Vinson [MVP]

  #5  
Old February 8th, 2008, 04:10 AM posted to microsoft.public.access.forms
J_Goddard via AccessMonster.com
external usenet poster
 
Posts: 221
Default Get data from previous records

Hi -

Sounds to me like Edit - Copy (Ctrl-C) and Edit - Paste (Ctrl-V) would work;
that seems too easy - am I missing something?

John


crtopher wrote:
Thankyou John and Allen.

My problem is that i am editing an existing record and need to go to another
record to get the data (and i need the whole field not just part) then go
back to the record i was just editing and paste the data....the problem, as i
understand it, is that by setting the default value, that only works when you
go to a new record...the default value won't come across to an existing
record, the feilds of which may, or may not, already have data in them.

once i have started entering data into a new record via a form (ie the record
is already created) i would like to go to another record, pinch some data

[quoted text clipped - 14 lines]

John W. Vinson [MVP]


--
John Goddard
Ottawa, ON Canada
jrgoddard at cyberus dot ca

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200802/1

  #6  
Old February 8th, 2008, 05:19 AM posted to microsoft.public.access.forms
Allen Browne
external usenet poster
 
Posts: 11,706
Default Get data from previous records

Hmm. So you need to open another instance of the same form to a different
record, and duplicate the particular fields onto the original instance while
it is still being edited.

It is possible to programmatically open another instance using the New
keyword. But I think it would be easier to create another form for this
purpose - perhaps one in Continuous Form view, so you can easily spin
through to the desired record, and then click the button on that form to
copy those values into the other form. One advantage of this approach is
that you can open this form in dialog mode. The code for the button's Click
event procedure would be really quite simple, e.g.:
With Forms("NameOfYourOriginalFormHere")
!SomeField = Me.SomeField
!AnotherField = Me.AnotherField
'etc
End With

If you really want to pursue opening another instance of the same form,
here's some info on that:
Managing Multiple Instances of a Form
at:
http://allenbrowne.com/ser-35.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"crtopher" wrote in message
...
Thankyou John and Allen.

My problem is that i am editing an existing record and need to go to
another
record to get the data (and i need the whole field not just part) then go
back to the record i was just editing and paste the data....the problem,
as i
understand it, is that by setting the default value, that only works when
you
go to a new record...the default value won't come across to an existing
record, the feilds of which may, or may not, already have data in them.



"John W. Vinson" wrote:

On Thu, 7 Feb 2008 17:56:01 -0800, crtopher
wrote:

once i have started entering data into a new record via a form (ie the
record
is already created) i would like to go to another record, pinch some
data
from some of the fields in that record and go back to the record i was
just
on, & put that data in the equivalent fields. The data i would need to
pinch
would be the same each each time (ie i don't need to select each time
what
fields to import).


It's not quite clear if this is what you mean, but you can set the
default
value of a field in the AfterUpdate event of the form, so that the field
will
be "sticky" - each time you enter a new record it will offer you the
value
from the previous record as a default (which can be changed and become
the new
default).

If you're trying to pinch PART of a field, that's harder, and it really
suggests that your table design may not be optimum. What is the nature of
the
data and what would be carried over?

John W. Vinson [MVP]


  #7  
Old February 8th, 2008, 08:37 AM posted to microsoft.public.access.forms
crtopher
external usenet poster
 
Posts: 42
Default Get data from previous records

Allen thank you...that sounds like a plan. I'll make another form to search
for the record, part of which i want to copy, then use your suggested code to
drop that back into the main form, which will obviously still be on the
record i was editing.

I'll try and get back to you...



"Allen Browne" wrote:

Hmm. So you need to open another instance of the same form to a different
record, and duplicate the particular fields onto the original instance while
it is still being edited.

It is possible to programmatically open another instance using the New
keyword. But I think it would be easier to create another form for this
purpose - perhaps one in Continuous Form view, so you can easily spin
through to the desired record, and then click the button on that form to
copy those values into the other form. One advantage of this approach is
that you can open this form in dialog mode. The code for the button's Click
event procedure would be really quite simple, e.g.:
With Forms("NameOfYourOriginalFormHere")
!SomeField = Me.SomeField
!AnotherField = Me.AnotherField
'etc
End With

If you really want to pursue opening another instance of the same form,
here's some info on that:
Managing Multiple Instances of a Form
at:
http://allenbrowne.com/ser-35.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"crtopher" wrote in message
...
Thankyou John and Allen.

My problem is that i am editing an existing record and need to go to
another
record to get the data (and i need the whole field not just part) then go
back to the record i was just editing and paste the data....the problem,
as i
understand it, is that by setting the default value, that only works when
you
go to a new record...the default value won't come across to an existing
record, the feilds of which may, or may not, already have data in them.



"John W. Vinson" wrote:

On Thu, 7 Feb 2008 17:56:01 -0800, crtopher
wrote:

once i have started entering data into a new record via a form (ie the
record
is already created) i would like to go to another record, pinch some
data
from some of the fields in that record and go back to the record i was
just
on, & put that data in the equivalent fields. The data i would need to
pinch
would be the same each each time (ie i don't need to select each time
what
fields to import).

It's not quite clear if this is what you mean, but you can set the
default
value of a field in the AfterUpdate event of the form, so that the field
will
be "sticky" - each time you enter a new record it will offer you the
value
from the previous record as a default (which can be changed and become
the new
default).

If you're trying to pinch PART of a field, that's harder, and it really
suggests that your table design may not be optimum. What is the nature of
the
data and what would be carried over?

John W. Vinson [MVP]



  #8  
Old February 8th, 2008, 08:38 AM posted to microsoft.public.access.forms
crtopher
external usenet poster
 
Posts: 42
Default Get data from previous records

Hi John

I have to copy data from several fields so i don't want to be flipping back
and forth several times to collect all the data i need

Cheers
Chris

"J_Goddard via AccessMonster.com" wrote:

Hi -

Sounds to me like Edit - Copy (Ctrl-C) and Edit - Paste (Ctrl-V) would work;
that seems too easy - am I missing something?

John


crtopher wrote:
Thankyou John and Allen.

My problem is that i am editing an existing record and need to go to another
record to get the data (and i need the whole field not just part) then go
back to the record i was just editing and paste the data....the problem, as i
understand it, is that by setting the default value, that only works when you
go to a new record...the default value won't come across to an existing
record, the feilds of which may, or may not, already have data in them.

once i have started entering data into a new record via a form (ie the record
is already created) i would like to go to another record, pinch some data

[quoted text clipped - 14 lines]

John W. Vinson [MVP]


--
John Goddard
Ottawa, ON Canada
jrgoddard at cyberus dot ca

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/200802/1


  #9  
Old February 11th, 2008, 07:47 AM posted to microsoft.public.access.forms
crtopher
external usenet poster
 
Posts: 42
Default Get data from previous records

Hi Allen

Just wanted to say your suggestion was perfect...just what i needed was the
idea to open another form. I put a search combo on it to find the record i
needed then used your little bit of code to take the values over to the first
form. Worked beautifully. Thank you

Cheers
Chris

"Allen Browne" wrote:

Hmm. So you need to open another instance of the same form to a different
record, and duplicate the particular fields onto the original instance while
it is still being edited.

It is possible to programmatically open another instance using the New
keyword. But I think it would be easier to create another form for this
purpose - perhaps one in Continuous Form view, so you can easily spin
through to the desired record, and then click the button on that form to
copy those values into the other form. One advantage of this approach is
that you can open this form in dialog mode. The code for the button's Click
event procedure would be really quite simple, e.g.:
With Forms("NameOfYourOriginalFormHere")
!SomeField = Me.SomeField
!AnotherField = Me.AnotherField
'etc
End With

If you really want to pursue opening another instance of the same form,
here's some info on that:
Managing Multiple Instances of a Form
at:
http://allenbrowne.com/ser-35.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"crtopher" wrote in message
...
Thankyou John and Allen.

My problem is that i am editing an existing record and need to go to
another
record to get the data (and i need the whole field not just part) then go
back to the record i was just editing and paste the data....the problem,
as i
understand it, is that by setting the default value, that only works when
you
go to a new record...the default value won't come across to an existing
record, the feilds of which may, or may not, already have data in them.



"John W. Vinson" wrote:

On Thu, 7 Feb 2008 17:56:01 -0800, crtopher
wrote:

once i have started entering data into a new record via a form (ie the
record
is already created) i would like to go to another record, pinch some
data
from some of the fields in that record and go back to the record i was
just
on, & put that data in the equivalent fields. The data i would need to
pinch
would be the same each each time (ie i don't need to select each time
what
fields to import).

It's not quite clear if this is what you mean, but you can set the
default
value of a field in the AfterUpdate event of the form, so that the field
will
be "sticky" - each time you enter a new record it will offer you the
value
from the previous record as a default (which can be changed and become
the new
default).

If you're trying to pinch PART of a field, that's harder, and it really
suggests that your table design may not be optimum. What is the nature of
the
data and what would be carried over?

John W. Vinson [MVP]



  #10  
Old April 10th, 2008, 02:07 PM posted to microsoft.public.access.forms
Vijay G. Muthumalai
external usenet poster
 
Posts: 1
Default Get data from previous records

Hi Chris,

I am going through the same problem. May I request you to share the code
for executing this, please?

Thanks
Vijay

"crtopher" wrote:

Hi Allen

Just wanted to say your suggestion was perfect...just what i needed was the
idea to open another form. I put a search combo on it to find the record i
needed then used your little bit of code to take the values over to the first
form. Worked beautifully. Thank you

Cheers
Chris

"Allen Browne" wrote:

Hmm. So you need to open another instance of the same form to a different
record, and duplicate the particular fields onto the original instance while
it is still being edited.

It is possible to programmatically open another instance using the New
keyword. But I think it would be easier to create another form for this
purpose - perhaps one in Continuous Form view, so you can easily spin
through to the desired record, and then click the button on that form to
copy those values into the other form. One advantage of this approach is
that you can open this form in dialog mode. The code for the button's Click
event procedure would be really quite simple, e.g.:
With Forms("NameOfYourOriginalFormHere")
!SomeField = Me.SomeField
!AnotherField = Me.AnotherField
'etc
End With

If you really want to pursue opening another instance of the same form,
here's some info on that:
Managing Multiple Instances of a Form
at:
http://allenbrowne.com/ser-35.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"crtopher" wrote in message
...
Thankyou John and Allen.

My problem is that i am editing an existing record and need to go to
another
record to get the data (and i need the whole field not just part) then go
back to the record i was just editing and paste the data....the problem,
as i
understand it, is that by setting the default value, that only works when
you
go to a new record...the default value won't come across to an existing
record, the feilds of which may, or may not, already have data in them.



"John W. Vinson" wrote:

On Thu, 7 Feb 2008 17:56:01 -0800, crtopher
wrote:

once i have started entering data into a new record via a form (ie the
record
is already created) i would like to go to another record, pinch some
data
from some of the fields in that record and go back to the record i was
just
on, & put that data in the equivalent fields. The data i would need to
pinch
would be the same each each time (ie i don't need to select each time
what
fields to import).

It's not quite clear if this is what you mean, but you can set the
default
value of a field in the AfterUpdate event of the form, so that the field
will
be "sticky" - each time you enter a new record it will offer you the
value
from the previous record as a default (which can be changed and become
the new
default).

If you're trying to pinch PART of a field, that's harder, and it really
suggests that your table design may not be optimum. What is the nature of
the
data and what would be carried over?

John W. Vinson [MVP]



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:30 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.