Rick,
Still can't get it. In my table the field I want to be
the one changing is called WO
The form is called WO, the table is called WO, the number
we want it to start from is 3025.
In the table i tried making WO a number field, is that
right? I also tried it as an autonumber field, niether
worked. I also tried making it the primary key. Still
no luck. Let me know what i'm doing wrong.
This is a copy and paste of what my code looks like.
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me![WO]) = True Then
Me![WO] = Nz(DMax("[WO]", "WO"), 0) + 1
End If
End Sub
-----Original Message-----
Leo said:
rick,
sorry i am kind of dumb. I dont know anything about VBA
code so i would need step by step instructions on where
to put that...
Open your form in design view and look at the events tab of the property sheet.
Double-Click on the BeforeUpdate event for the form (not a control) and the entry
"[Event Procedure]" should appear. If it doesn't you can select it from the
drop-down list of entries.
Once "[Event Procedure]" is showing in the property,
click on the build button to the
right [...]. You should now be in the code module window for the form and Access
will have already inserted the lines to define the
BeforeUpdate sub-routine. Just
paste my code in between the lines that were created for you. When finished. it
should look similar to ...
Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Me![ID]) = True Then
Me![ID] = Nz(DMax("[ID]", "MyTable"), 0) + 1
End If
End Sub
You will need to substitute the actual names of your number field and table in the
code.
.