| re: Assign textbox value from command button
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
<dskillingstad@gmail.com> wrote in message
news:1126040916.190878.72630@g49g2000cwa.googlegro ups.com...[color=blue]
> 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
>[/color] |