You don't need to do anything with the member form. You can do this from
the
Payment form.
I will invent my own names, you may need to change them.
First, add a text box to the Payment form. txtExpireDate
It will be an unbound control.
Now, we need to load txtExpireDate with the current date for the member in
the current record. That should be done in the Current event of the form.
Again, I don't know your names, so these are just dummies:
Me.txtExpireDate = DLookup("[EXPIRE_DATE]", "tblMembers", "MEMBER_NO =
'" & Me.txtMemberNo & "'")
Now, each time you move to a different record or create a new record, the
expiration date will show up on the form. Then, to update the date and
add a
year to it when the payment is entered, use the After Update event of the
control where you enter the payment:
Private Sub txtPayment_AfterUpdate()
If Not IsNull(Me.txtPayment) Then
Me.txtExpireDate = DateAdd("yyyy", 1, Me.txtExpireDate) c
End If
End Sub
Note, the last line (CurrentDb.Execute.....) updates the expiration date
in
the member table.
Don't give up. Post back with any questions.
--
Dave Hargis, Microsoft Access MVP
Dave Eliot said:
When I designed the payment form I only chose the payment table for
fields.
Now, I can't figure out how to add "a control on your payment form named
ExpDate that is bound to the field in the recordset that is the
expiration
date." Each member's expiration date is stored in the Members table.
So . . .
Is there a way to add a button to the Members form that could use
me.expDate = DateAdd("yyyy", 1, Nz(Me.expDate,Date))
and change the ExpDate right before my very eyes?
I'm soon giving up on this one. I guess you can tell I'm new at this.
You need a control on your payment form named ExpDate that is bound to
the
field in the recordset that is the expiration date.
Then do as Eric said, except DO NOT use the calculation that way. You
way
is the correct way:
me.expDate = DateAdd("yyyy", 1, Nz(Me.expDate,Date))
This way you don't loose a day each year and it is more obvious to the
reader what you are doing.
--
Dave Hargis, Microsoft Access MVP
:
Well, I tried that and got a Compile error: Method or data member not
found.
and ".ExpDate =" was highlighted.
The problem may be that the Members form is tied to the table called
Members, and the Payment form is tied to the table called Payments. Se
perhaps there's more to this.
Thanks again.
message
In the after update event of the renewal check box add
if checkbox = -1 then
me.expDate = date() + 364
end if
:
On a form called Members I have a field named ExpDate, as well as a
button
that opens a payment form. On the payment form, there are check
boxes
for
new and renewal. as well as a button to close the payment form (and
return
to the Members form). How can I have the ExpDate on the Members
form
increase one year if the renewal check box is "true" on the payment
form?
Am I asking too much? If so, I'm willing to put a button on the
Members
form
that would increase the ExpDate by a year. I did find "DateAdd(
"yyyy",
1,
ExpDate)" but couldn't make it work no matter how I tried.
Thanks to all of you who provide so much help.