add avlue to 2 or more fields ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hallo, i did a search but didn't find anything so here's my question :
i want to type in a value in a form. all right. but i want that typed value
to be added in 2 fields in a tabel. in my case : in a today_date and an
experiation_date.
the standard value for the exp_date will be today_date + 28, but i will be
able to change that date if needed.
is this possible ?
i dont know anything about visual basic etc. so a bit of simple explenation
would be nice.
btw i use access97
greetings, johan.
 
You can use the AfterUpdate event of the "today_date" control to put the
"+28" value into the "experiation_date" control:

Private Sub today_date_AfterUpdate()
Me.experiation_date.Value = DateAdd("d", 28, Me.today_date.Value)
End Sub

To add this event procedure to the AfterUpdate event of the control, open
the form in design view, click on the "today_date" control, click on
Properties icon on toolbar, click on Event tab, click in box next to After
Update, select "[Event Procedure]" from the dropdown list, click on the
"three-dot" box at far right side of box, and you'll see Visual Basic Editor
(VBE) open with the first and last lines of what I've typed above shown,
with a blank line in between (the cursor will be on the blank line).

Type the second line onto that second line, close VBE, and save the form.
Now, when your form is opened and you type a value into the "today_date"
textbox, the "+28" day will be filled in.
 
thanks ken, this helped me out !
i have been searching for this for almost 3 days.......
i have 1 simple further question : if i want to do this with a name or some
other type of data, will the expression still be the same ?
thanks again, johan tantejo
btw is there a book where this type of information is in ?

Ken Snell said:
You can use the AfterUpdate event of the "today_date" control to put the
"+28" value into the "experiation_date" control:

Private Sub today_date_AfterUpdate()
Me.experiation_date.Value = DateAdd("d", 28, Me.today_date.Value)
End Sub

To add this event procedure to the AfterUpdate event of the control, open
the form in design view, click on the "today_date" control, click on
Properties icon on toolbar, click on Event tab, click in box next to After
Update, select "[Event Procedure]" from the dropdown list, click on the
"three-dot" box at far right side of box, and you'll see Visual Basic Editor
(VBE) open with the first and last lines of what I've typed above shown,
with a blank line in between (the cursor will be on the blank line).

Type the second line onto that second line, close VBE, and save the form.
Now, when your form is opened and you type a value into the "today_date"
textbox, the "+28" day will be filled in.

--

Ken Snell
<MS ACCESS MVP>



tantejo said:
hallo, i did a search but didn't find anything so here's my question :
i want to type in a value in a form. all right. but i want that typed
value
to be added in 2 fields in a tabel. in my case : in a today_date and an
experiation_date.
the standard value for the exp_date will be today_date + 28, but i will be
able to change that date if needed.
is this possible ?
i dont know anything about visual basic etc. so a bit of simple
explenation
would be nice.
btw i use access97
greetings, johan.
 
The basic concept of using the AfterUpdate event likely will work for what
you seek for other data types, although the expression that you would use
probably won't involve the DateAdd function.

As for a book, any book on ACCESS has this type of information in it.
--

Ken Snell
<MS ACCESS MVP>



tantejo said:
thanks ken, this helped me out !
i have been searching for this for almost 3 days.......
i have 1 simple further question : if i want to do this with a name or
some
other type of data, will the expression still be the same ?
thanks again, johan tantejo
btw is there a book where this type of information is in ?

Ken Snell said:
You can use the AfterUpdate event of the "today_date" control to put the
"+28" value into the "experiation_date" control:

Private Sub today_date_AfterUpdate()
Me.experiation_date.Value = DateAdd("d", 28, Me.today_date.Value)
End Sub

To add this event procedure to the AfterUpdate event of the control, open
the form in design view, click on the "today_date" control, click on
Properties icon on toolbar, click on Event tab, click in box next to
After
Update, select "[Event Procedure]" from the dropdown list, click on the
"three-dot" box at far right side of box, and you'll see Visual Basic
Editor
(VBE) open with the first and last lines of what I've typed above shown,
with a blank line in between (the cursor will be on the blank line).

Type the second line onto that second line, close VBE, and save the form.
Now, when your form is opened and you type a value into the "today_date"
textbox, the "+28" day will be filled in.

--

Ken Snell
<MS ACCESS MVP>



tantejo said:
hallo, i did a search but didn't find anything so here's my question :
i want to type in a value in a form. all right. but i want that typed
value
to be added in 2 fields in a tabel. in my case : in a today_date and an
experiation_date.
the standard value for the exp_date will be today_date + 28, but i will
be
able to change that date if needed.
is this possible ?
i dont know anything about visual basic etc. so a bit of simple
explenation
would be nice.
btw i use access97
greetings, johan.
 
Back
Top