creating running numbers starting with 42990

eu6en3

New member
Local time
Today, 02:43
Joined
Jul 11, 2012
Messages
7
Hi,

i am super new in using access and i am facing a problem with creating a running number starting with 42990..

I try creating with Auto number but the number start with 1 and i can't change the seq to 42990. Can anyone please help me. thanks!
 
Not AutoNumber but NUMBER.
Look at "DemoAutoNum42990A20022003.mdb (attachment, zip).
Open Form1 and try to enter some records.
Look at Table1, VBA.
 

Attachments

Not AutoNumber but NUMBER.
Look at "DemoAutoNum42990A20022003.mdb (attachment, zip).
Open Form1 and try to enter some records.
Look at Table1, VBA.

Hi Mstef, i am unable to open the file.. please help.. Thanks!
 
Hi all,

i have looked at the Zip file.. How do you lock the Form 1 f1ID and create a running number starting at 42990?

Please help thanks!
 
Dear John,

So sorry, i do not understand the (Form's On Current Event).. where do i find this On Current to key in the Code?

Also, after keying in the codes, how do i lock column in the form so that user can only key in the fields that are required?

Thanks!
 
With you form in design view, click in the small square at the intersection of the Vertical and Horizontal rulers ensure that there is a small black square within this square.

attachment.php





Select Event Procedure from the drop down box and click ellipsis button and put your code in the area between Private Sub Form_Current() and End Sub

attachment.php


Be sure to change the field names to reflect the reality of your DB
 

Attachments

  • Capture.PNG
    Capture.PNG
    44.9 KB · Views: 315
  • Capture2.PNG
    Capture2.PNG
    14.5 KB · Views: 295
Hi,

I have found the box and i copy the codes in.. But it still doesn't work. You have mention something about the field name... Where do i change it?

In the form, the running number is under "PO number" column, and the form is created under "PO generator" table.
 
Change the portions highlighted in Red to reflect the reality that exists in your DB;
Code:
If Me.[COLOR="Red"]YourCounterField[/COLOR] = 0 Or IsNull(Me.[COLOR="Red"]YourCounterField[/COLOR]) Then
        Me.[COLOR="Red"]YourCounterField[/COLOR] = Nz(DMax("[COLOR="Red"]YourCounterField[/COLOR]", "[COLOR="Red"]YourTableName[/COLOR]"), X) + 1
    End If
 
i type the following and end up with the error below

If Me.PO number = 0 Or IsNull(Me.PO number) Then
Me.PO Number = Nz(DMax("PO number", "PO"), 42990) + 1
End If

Compile error:

syntax error
 
You should avoid spaces and other special characters in field and object names as the will cause you no end of hurt (as you are now discovering) Limit your self to alpha and numeric characters and the underscore (_), refer to my example code in previous posts, see there was a very good reason I formatted it that way ;)

Now to overcome your current predicament you must enclose your field names in square brackets;

Code:
If Me.[COLOR="Red"][[/COLOR]PO number[COLOR="Red"]][/COLOR] = 0 Or IsNull(Me.[COLOR="Red"][[/COLOR]PO number[COLOR="Red"]][/COLOR]) Then
Me.[COLOR="Red"][[/COLOR]PO Number[COLOR="Red"]][/COLOR] = Nz(DMax("PO number", "PO"), 42990) + 1
End If
 
Last edited:
Thanks! i have successfully created the running number option.. but another problem arises..

Whenever i create new data base.. the PO number is auto generated.. but when i refer back to my table (PO).. It only shows the latest creation and the rest of the records is lost... :banghead:
 
Thanks! i have successfully created the running number option.. but another problem arises..

Whenever i create new data base.. the PO number is auto generated.. but when i refer back to my table (PO).. It only shows the latest creation and the rest of the records is lost... :banghead:

I'm sorry but I don't think I understand :eek:
 

Users who are viewing this thread

Back
Top Bottom