Auto Generate Number Error

I cut down the previous sample.

The form has three fields. You need to put something (Anything) in the middle control in order to create a record and to run the DMax.

All you have to do in your Database is to modify the DMax line of code.

Post back if you have a problem.
 

Attachments

Thank you for breaking it down further and I do understand the concept. But I am still trying to avoiding having to type in (anything). With my current set up, I have an On Load event for the form that obtains the auto generated number:

Code:
[FONT=Arial][SIZE=3]Private Sub Form_Load()[/SIZE][/FONT]
[FONT=Arial][SIZE=3]'Assign a new Requisition Number[/SIZE][/FONT]
[FONT=Arial][SIZE=3] RequisitionNumber = NewRequisitionNumber[/SIZE][/FONT]
[FONT=Arial][SIZE=3]End Sub[/SIZE][/FONT]

That event triggers the function to auto assign the number without any user input. So my question is, other than the very first input of setting the values of [ABC], [13], [60000], will DMax allow me to run a similar function that my current code performs? Or will the user always have to type in a value?
 
If NewRequisitionNumber is the name on the Sub that generates a new number via DMax then you can use it.
However,
Calling it on the Load event means that every time you open the form a new number will be allocated to the Record that is first opened. Even if a number has been loaded previously.
You speak about not having to enter any Data. What is the Form for if it is not to enter Data? Do you only have one field in your Table?
I do not understand where you are going.
Normally a person would have a Form to e.g. enter Invoices. Each Invoice would require a new unique consecutive number. The number is created, using DMax, as soon as the user starts to enter data. Rather I should say when the user triggers an event to run the DMax code.
 
Last edited:
I think it is hard when you are not seeing what I see in my database. I posted a partial sample of my database in post #11. I hope I can better explain it here.

In my full copy, I have duplicate copy of the form [AddPurchaseOrder], called [ReviewPurchaseOrder] used for reviewing/editing/doing whatever else is needed, where the NewRequisitionNumber function is not used. So there would not be another number assigned.

The on load event is exactly what I want. The form [AddPurchaseOrder] is specifically for new orders and will be assigned the number. So if a user accidently opens this form and closes, the number will be stored with the assigned number and later recalled on [ReviewPurchaseOrder].

Both forms are for entering purchase orders with multiple fields from multiple tables, what I am trying to avoid is having the user enter the Requisition Number on [AddPurchaseOrder] that is now auto generated with the On Load function. There will never be a time when the user opens [ReviewPurchaseOrder] and manually types a requisition number because it was already generated previously.

So I’m trying to understand the DMax function to incorporate it by applying the concept of what I currently have.
 
Simply put you want to assign the auto generated number when the Form opens.

There is no reason then why you can't simply use the DMax code to do this. Choosing the correct Event is the only problem.

If the ON Load Event works for you then use it. Just be sure to test it throughly. Even better give it to someone else and ask then to try and break it. Give them very little instructions. We want them to do it their way not the way you think it should be done.

If we understand each other then this problem should be solved. Or am I not explaining some thing properly to you.
 

Users who are viewing this thread

Back
Top Bottom