Sorry about the jargon, Maria. I didn't know how much you knew.
Use a form to input your data, not a table.
Open the form in Design View.
Right Click on the Check Number control (text box)
Go to Properties
Click on the Event tab
Click next to AfterUpdate, choose Event Procedure, click just right of that
and open up a code page.
Just above where it says
End Sub
put the code
Dim LastNum as Long
LastNum = NZ(DMax("[Check Number]","TblOfCheckNumbers"),0)
If Me.[Check Number] > LastNum + 1 Then
Me.[Check Number].Undo
MsgBox "That was not the next check number. The previous check number was "
& LastNum
End If
Replace TblOfCheckNumbers with the real name of the table that contains the
check number.
I'm assuming above that you don't want the code to automatically fill in the
next check number but if you do, open an 'After Update' code page for a
different control in your form, one you always fill in when you are entering
a new record (perhaps the date?) and enter:
Dim LastNum as Long
LastNum = NZ(DMax("[Check Number]","TblOfCheckNumbers"),0) + 1
If Me.[Check Number] =LastNum
End If
Put things in the After Update event of a control means that when you have
finished entering something into a text box, or choosing something with a
combo box, your code will happen.
One problem you will have though, if you really do have a field in your
table called Date, then before you do much else, you really ought to rename
it.
Look up Access Reserved Words field names to find out what may happen if you
don't. Call it XDate or anything else (and be prepared to spend time mending
queries, reports and forms)
You can always change labels in forms and reports to say Date so long as the
field doesn't
Evi
Maria (MAC) said:
Thank you for your response (I apologize for the delay this is my first time
using this service and I was having some problems in getting through).
I have never taken a course in ACCESS, which I should, so what I know is by
asking questions and just experimenting. So I apoligize if I sound ignorant,
which I am.
You are correct the cheque number is always be 1 number higher than the last
check. I do not know what you mean about "After Update Event of the Cheque
Number field have this code (swap the .....)" is. Also, where should I place
the formula below in the "descripton" under TABLE?
The table has the following "main" information to complete (there are more):
Date (Text with Input Mask - short date)
Check Number (Number not text)
Amount (Currency)
Payee (Memo)
Issuance (Memo)
Address (Memo)
Thank you very much
Evi said:
You mean that if anyone enters a cheque then it should always be 1 number
higher than the last check that was entered? Here is a possible, if you
don't have lots of people inputting at the same time.
In your form, in the After Update Event of the Cheque Number field have this
code.
(swap the field and table names for your own) (I'm presuming that your
ChequeNumbers are numbers and not text)
Dim LastNum as Long
LastNum = NZ(DMax("[CheckNumber]","TblOfCheckNumbers"),0)
If Me.CheckNumber > LastNum + 1 Then
Me.CheckNumber.Undo
MsgBox "That was not the next check number. The previous check number was "
& LastNum
End If
Evi
I created a log for cashier's check in MICROSOFT ACCESS PROGRAM - everyone
is
inputting but sometime they forget so I have to go back and research the
missing information. My question is how can I format either in the "field
name" or in the "data type" to ensure that the check number entered is in
numerical order if is not, the system is to reject it (like a control).