Tom-
It's best to create the value just as the record is being saved rather than when
someone goes to a new record. If this is a multi-user database, two people
could start a new record and get the same "next" number, but only the first one
to save would win. Do it in the Form_BeforeUpdate event:
Private Sub Form_BeforeUpdate(Cancel As Integer)
' If on a new row
If Me.NewRecord Then
' Get the "next" PatientID
Me.PatientID = NZ(DMax("PatientID", "tblPatients"), 0) + 1
End If
End Sub
John Viescas, author
Microsoft Office Access 2010 Inside Out
Microsoft Office Access 2007 Inside Out
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
-----Original Message-----
From: MS_Access_Professionals@yahoogroups.com
[mailto:MS_Access_Professionals@yahoogroups.com] On Behalf Of Tom
Sent: Tuesday, November 01, 2011 10:19 PM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Question re Access Database For Free Clinic
Hi All,
I wrote this board several months ago that my wife and I volunteered to do
an Access database for a free clinic in the area. I did the analysis and my
wife worked with access to create the database, queries, forms, etc ... I am
pleased, surprised and proud to report that my wife did a great job with only
minimal access training and without seeking any outside help as I had expected -
until now :-) . We will be demonstrating the database to the clinic Friday.
She does have 1 question that is probably fairly simple for you experts.
Question:
When the form is brought up to "add a new patient", she would like to
automatically fill-in the "Patient I.D." into the the form. It should be the
last (highest) Patient I.D. in the database plus 1. The Patient I.D. is the
primary key in the Patient_Table but it is not computer generated. Can someone
please give her some help regarding how to do this including the proper syntax
for any query/macro/condition that is necessary to use to accomplish this. Any
help will be much appreciated.
Thanks,
Tom
------------------------------------
Yahoo! Groups Links
Selasa, 01 November 2011
RE: [MS_AccessPros] Question re Access Database For Free Clinic
__._,_.___
MARKETPLACE
.
__,_._,___
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar