From: TonyWilliams via AccessMonster.com on
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

From: John W. Vinson on
On Sat, 20 Feb 2010 10:23:22 GMT, "TonyWilliams via AccessMonster.com"
<u56994(a)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]
From: TonyWilliams via AccessMonster.com on
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/Forums.aspx/access-forms/201002/1

From: John W. Vinson on
On Sun, 21 Feb 2010 10:18:44 GMT, "TonyWilliams via AccessMonster.com"
<u56994(a)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]
From: TonyWilliams via AccessMonster.com on
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