By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,667 Members | 2,261 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,667 IT Pros & Developers. It's quick & easy.

Assign textbox value from command button

P: n/a
I'm trying to assign a custom value to a textbox. Here's what I have.

I've created a module and "default value" code for a textbox which
generates a custom auto-number (yyyy-0000) when a New Record button is
clicked. The code checks the table for the highest value and then
assigns 1 and inserts the value. I have a second text box which needs
the same type of custom auto-number which has to be generated from a
second command button. The numbers in the two text boxes are not
related to each other sequentially.

I have a main form and a subform. Both text boxes are on the main
form, but, one textbox is related to records on the main form, and the
second textbox is related to records on the subform. There is a reason
for having the second textbox on the mainform rather than in the
subform. The subform may have 1-10 records related to the one record
on the mainform.

Clear as mud??

What I'm trying to do, is click a button and assign an auto-number in
the second textbox, similar to the way the New Record button does for
the first textbox. When I apply the same code (revied for second
textbox) when I click the New Record button for the first text box, it
assigns a number to the second text box. I need them to be independant
of each other. I've tried running code , running macro etc. in the
OnClick event and nothing.

Any help would be appreciated.
dskillingstad

Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
To assign a value to a textbox in a button's click event, you would use
something like:

Me.txtMyTextbox = Value

where txtMyTextbox is the name of the textbox you want to assign the value
to. Make sure you have the correct name in your code for the textbox you are
wanting to update.

--
Wayne Morgan
MS Access MVP
<ds***********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I'm trying to assign a custom value to a textbox. Here's what I have.

I've created a module and "default value" code for a textbox which
generates a custom auto-number (yyyy-0000) when a New Record button is
clicked. The code checks the table for the highest value and then
assigns 1 and inserts the value. I have a second text box which needs
the same type of custom auto-number which has to be generated from a
second command button. The numbers in the two text boxes are not
related to each other sequentially.

I have a main form and a subform. Both text boxes are on the main
form, but, one textbox is related to records on the main form, and the
second textbox is related to records on the subform. There is a reason
for having the second textbox on the mainform rather than in the
subform. The subform may have 1-10 records related to the one record
on the mainform.

Clear as mud??

What I'm trying to do, is click a button and assign an auto-number in
the second textbox, similar to the way the New Record button does for
the first textbox. When I apply the same code (revied for second
textbox) when I click the New Record button for the first text box, it
assigns a number to the second text box. I need them to be independant
of each other. I've tried running code , running macro etc. in the
OnClick event and nothing.

Any help would be appreciated.
dskillingstad

Nov 13 '05 #2

P: n/a
Thanks for the response. I'll give it a try.

dskillingstad
Wayne Morgan wrote:
To assign a value to a textbox in a button's click event, you would use
something like:

Me.txtMyTextbox = Value

where txtMyTextbox is the name of the textbox you want to assign the value
to. Make sure you have the correct name in your code for the textbox you are
wanting to update.

--
Wayne Morgan
MS Access MVP
<ds***********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I'm trying to assign a custom value to a textbox. Here's what I have.

I've created a module and "default value" code for a textbox which
generates a custom auto-number (yyyy-0000) when a New Record button is
clicked. The code checks the table for the highest value and then
assigns 1 and inserts the value. I have a second text box which needs
the same type of custom auto-number which has to be generated from a
second command button. The numbers in the two text boxes are not
related to each other sequentially.

I have a main form and a subform. Both text boxes are on the main
form, but, one textbox is related to records on the main form, and the
second textbox is related to records on the subform. There is a reason
for having the second textbox on the mainform rather than in the
subform. The subform may have 1-10 records related to the one record
on the mainform.

Clear as mud??

What I'm trying to do, is click a button and assign an auto-number in
the second textbox, similar to the way the New Record button does for
the first textbox. When I apply the same code (revied for second
textbox) when I click the New Record button for the first text box, it
assigns a number to the second text box. I need them to be independant
of each other. I've tried running code , running macro etc. in the
OnClick event and nothing.

Any help would be appreciated.
dskillingstad


Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.