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  

Copying data from previous record



 
 
Thread Tools Display Modes
  #1  
Old February 20th, 2010, 10:23 AM posted to microsoft.public.access.forms
TonyWilliams via AccessMonster.com
external usenet poster
 
Posts: 117
Default Copying data from previous record

I have a form that has a combo box (cmbmonth) where the value is stored in a
field txtmonth. The users normally input a batch of records at a time. So
what I would like to happen is that they select a value from the combo box on
the first record but as they move to a new record the value is carried over
to the same control on the new record. This should happen with every new
record until they decide to select a new value and then that new value is
carried forward until they decide to select another new valu and so on.
Can anyone help with this?
Thanks
Tony

--
Why don't my grey cells communicate with each as fast as they used to? I hate
getting old!

Message posted via http://www.accessmonster.com

  #2  
Old February 20th, 2010, 10:11 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Copying data from previous record

On Sat, 20 Feb 2010 10:23:22 GMT, "TonyWilliams via AccessMonster.com"
u56994@uwe wrote:

I have a form that has a combo box (cmbmonth) where the value is stored in a
field txtmonth. The users normally input a batch of records at a time. So
what I would like to happen is that they select a value from the combo box on
the first record but as they move to a new record the value is carried over
to the same control on the new record. This should happen with every new
record until they decide to select a new value and then that new value is
carried forward until they decide to select another new valu and so on.
Can anyone help with this?
Thanks
Tony


You can use the AfterUpdate event of a control to set that control's own
DefaultValue property:

Private Sub cmbMonth_AfterUpdate()
Me!cmbMonth.DefaultValue = """" & Me!cmbMonth & """"
End Sub

The quotes are required because (whatever the datatype of the field) the
default vallue must be a string.
--

John W. Vinson [MVP]
  #3  
Old February 21st, 2010, 10:18 AM posted to microsoft.public.access.forms
TonyWilliams via AccessMonster.com
external usenet poster
 
Posts: 117
Default Copying data from previous record

Thanks John I tried that and got an error message:
Runtime error 438
Object doesn't support this object or method.

When I looked at the VBA window after the full stop after nonth the only
choice I had was Value and not DefaultValue.

Any ideas?
Thanks for your help
Tony

John W. Vinson wrote:
I have a form that has a combo box (cmbmonth) where the value is stored in a
field txtmonth. The users normally input a batch of records at a time. So

[quoted text clipped - 6 lines]
Thanks
Tony


You can use the AfterUpdate event of a control to set that control's own
DefaultValue property:

Private Sub cmbMonth_AfterUpdate()
Me!cmbMonth.DefaultValue = """" & Me!cmbMonth & """"
End Sub

The quotes are required because (whatever the datatype of the field) the
default vallue must be a string.


--
Why don't my grey cells communicate with each as fast as they used to? I hate
getting old!

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

  #4  
Old February 21st, 2010, 11:53 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Copying data from previous record

On Sun, 21 Feb 2010 10:18:44 GMT, "TonyWilliams via AccessMonster.com"
u56994@uwe wrote:

Thanks John I tried that and got an error message:
Runtime error 438
Object doesn't support this object or method.

When I looked at the VBA window after the full stop after nonth the only
choice I had was Value and not DefaultValue.


This is clearly a typo, but I'm baffled by what "after nonth" might mean.

My suggestion was intended to be that you open the Form in design view; select
the combo box; view its Properties; and click the ... icon next to the
"AfterUpdate" line on the Events tab. If you then select "Code Builder" you
will be put into the VBA editor for that event, with the Sub and End Sub lines
filled in for you. You would type in

Me!cmbMonth.DefaultValue = """" & Me!cmbMonth & """"

between the Sub and End Sub lines.

If that isn't what you did, please explain.
--

John W. Vinson [MVP]
  #5  
Old February 22nd, 2010, 09:27 AM posted to microsoft.public.access.forms
TonyWilliams via AccessMonster.com
external usenet poster
 
Posts: 117
Default Copying data from previous record

Hi John My apologies, yes it was a typo (brain working faster than the
fingers for a change!). What I did was exactly as you said and when it didn't
work I changed the ! to a full stop and then looked to see what the choices
were in the drop down list when I input a full stop after cmbmonth. That's
when I could only see Value as a choice. HOWEVER I 've just pasted your code
in again and this time it worked fine. No idea what I must have done the
first time.
Many thanks.
Tony
PS The problem with all of this is how do I get my ageing brain to remember
all these wonderful tips and hints that you guys give me so that I can use
them again? White cell deterioration is one of the most frustrating parts of
getting old!

John W. Vinson wrote:
Thanks John I tried that and got an error message:
Runtime error 438
Object doesn't support this object or method.

When I looked at the VBA window after the full stop after nonth the only
choice I had was Value and not DefaultValue.


This is clearly a typo, but I'm baffled by what "after nonth" might mean.

My suggestion was intended to be that you open the Form in design view; select
the combo box; view its Properties; and click the ... icon next to the
"AfterUpdate" line on the Events tab. If you then select "Code Builder" you
will be put into the VBA editor for that event, with the Sub and End Sub lines
filled in for you. You would type in

Me!cmbMonth.DefaultValue = """" & Me!cmbMonth & """"

between the Sub and End Sub lines.

If that isn't what you did, please explain.


--
Why don't my grey cells communicate with each as fast as they used to? I hate
getting old!

Message posted via http://www.accessmonster.com

  #6  
Old February 22nd, 2010, 04:45 PM posted to microsoft.public.access.forms
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Copying data from previous record

On Mon, 22 Feb 2010 09:27:17 GMT, "TonyWilliams via AccessMonster.com"
u56994@uwe wrote:

PS The problem with all of this is how do I get my ageing brain to remember
all these wonderful tips and hints that you guys give me so that I can use
them again? White cell deterioration is one of the most frustrating parts of
getting old!


I'm 63 and I know JUST what you mean... in fact I wince a tiny bit when I see
your .sig! One reason I'm active here is to just keep my brain exercised. Good
luck and glad I was able to help!
--

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 06:45 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.