Auto dates

P

pompeyboyUSA

I am trying to get a date field to automatically update -50 days from a date
entered in another box. I have done it with the form, but it doesn't update
in the table. Please help!!!
 
P

pompeyboyUSA

Yes I know. Any ideas why? It is showing the details in the form, after
closing down the database and re-opening it. I have the dates showing (-50
days from the source date) for all 150 records I have input so far. It just
isn't populating the field in the table.

Charlie
 
G

Graham R Seach

Charlie,

<<Any ideas why?>>
No. You haven't given me enough information.

If I understand you correctly, you have two textboxes; one (I'll call
txtDate) that contains the reference date; the other (I'll call txtNewDate)
that will contain txtDate-50 days.

txtNewDate probably has a DefaultValue something like this:
=DateAdd("d", -50, Forms!frmMyForm!txtSomeTextBox)

If not, then you probably have code to update txtNewDate based on what the
user enters in txtDate:
Private Sub txtDate_AfterUpdate()
Me!txtNewDate = DateAdd("d", -50, Me!txtDate)
End Sub

And you're saying the value in txtNewDate does not update a table field when
you (a) move to another record, or (b) close the form.

There are only two things that can be going wrong:

1. Something is causing the form to NOT save the record. This could be:
(a) Some sort of error prior to or during the save; or
(b) Somewhere, you have Me.Undo.

To test it, write the following code in the form's BeforeUpdate and
AfterUpdate events, and see what happens:
Private Sub Form_BeforeUpdate(Cancel As Integer)
MsgBox "BeforeUpdate: " & Me!txtDate & vbCrLf & Me!txtNewDate
End Sub

Private Sub Form_AfterUpdate()
MsgBox "AfterUpdate: " & Me!txtDate & vbCrLf & Me!txtNewDate
End Sub

2. txtNewDate is not bound, or isn't bound to the field you think it is.

If neither of these things highlight the problem, we'll need to deep a
little deeper, but you will have to part with more information than you have
so far.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia

Microsoft Access 2003 VBA Programmer's Reference
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0764559036.html
 
P

pompeyboyUSA

Graham,

Thank you for this, it has certainly given me some good stuff to go on. I
will test it tomorrow and let you know how I get on.

Many thanks

Charlie
 
P

pompeyboyUSA

Graham,

Thanks for your time so far, but I think this is beyond my skills! I am
completely lost, but my self pride won't allow me to give up! is there any
way I can send you a blank version of the database for you to look at? I
feel as though I am close to achieving the result, but need a little more
guidance.

Thanks

Charlie
 
Top