Some records not saving?

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

Guest

Hi, I have a database that is used for keeping a list of companies (with
contact info), individual employees within those companies (with contact
info) and how many copies of a publication has been sent to the individuals
(along with dates sent, etc.)

I have a form (General Organizations) that opens up the info for each
company - on the bottom of this form is a button at the bottom to open up a
form (Individuals) that filters for the individuals within that company and
at the bottom of that form I have another button so that I can open up the
Mailing Info form.

The General Organizations and the Individuals are linked and the Mailing
Info is linked to the Individuals.

For some reason some of my records are saving and some are not. Somehow the
Mailing Info one is the only one (so far) that appears to save properly each
time.

Any ideas or suggestions? If you need more info let me know.

(My BF is a programmer so I usually get him to help but he is in a meeting
most of today and I'm getting frustrated.)
 
So then I'm wondering if it has to do with my Before Update on my "Last
Updated" date fields. (There is none on my Mailing Info form.)

Here is the code for the Individuals Form:

Private Sub Individuals_Canada_Updated_BeforeUpdate(Cancel As
Integer)
[Individuals_Canada_Updated] = Format(Date, "medium date")

End Sub

It is the same for the General Organizations Form (except the name changes)

Is there something wrong with it?

I also have made close buttons for all my forms and most are set as popups.

Amanda
 
I also forgot to say that I have entered the exact same data a few times just
to test it out. Sometimes it worked sometimes it didn't.
 
Okay, so you do have a command button that uses the Close action/method? As
per the reference given previously, that could be the cause of your data
loss.

To test that idea, enter a value and try closing the form with X at the
right end of the form's title bar instead. If that solves the problem, then
follow the advice in the article.

The code in the BeforeUpdate of the control should not cause the problem.
Note that the code probably does not work as expected, because it will only
run if you manually type something into the Individuals_Canada_Updated
control, and then whatever you entered there is lost because the code
assigns a different value there, and the value assigned is a text value
representing a date, being assigned to whatever kind of field the
Individuals_Canada_Updated is. If you wanted to record the date when any
part of this record was changed, use the BeforeUpdate event of the form (not
the control), and just assign the date, i.e.:

Private Sub Form_BeforeUpdate(Cancel As Integer)
Me.Individuals_Canada_Updated = Date
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Amanda said:
So then I'm wondering if it has to do with my Before Update on my "Last
Updated" date fields. (There is none on my Mailing Info form.)

Here is the code for the Individuals Form:

Private Sub Individuals_Canada_Updated_BeforeUpdate(Cancel As
Integer)
[Individuals_Canada_Updated] = Format(Date, "medium date")

End Sub

It is the same for the General Organizations Form (except the name
changes)

Is there something wrong with it?

I also have made close buttons for all my forms and most are set as
popups.

Amanda



Allen Browne said:
If your form is bound to a table or query, Access automatically saves the
record when you enter it.

At least it's supposed to. There is one glaring flaw where Access just
throws away what you entered without telling you. Details in:
Losing data when you close a form
at:
http://members.iinet.net.au/~allenbrowne/bug-01.html
 
Back
Top