Autonumber not generating unique number

Format is only for display, it wouldn't affect the data.

Once you've understood the DMax function, you would set the PayeeID value on the Before_Insert even of your form.
 
ooohhh icic. I will look into it.vbaInet thank u very much for ur help. really appreciate the effort :D thanks!
 
No probs ds_8805. You're welcome.
 
hey I just looked up the DMax function and did the following code
Me.PayeeID.Value = DMax("PayeeID", "[Info of Payee]")

however, it does not seem to work. any idea wat is the problem?
 
sorry the error it gives me is that i cannot assign a value for this object.
 
Me!PayeeID = DMax("[PayeeID]", "[Info of Payee]") + 1

Try that.
 
hey this works. But right the value it shows for payee id is actually an existing record with alot of empty records. ( eg like it has only 1 field filled). I tried putting - in the empty fields but it does not seem to solve the problem
 
Then are you sure Info Of Payee is the right table? Shouldn't it be your Payee table?
 
yup. cos I just said it as payee table for reference while asking my doubt. the actual name of the payee table is info of payee
 
Me!PayeeID = CInt(Nz(DMax("[PayeeID]", "[Info Of Payee]"), 0)) + 1
 
hey thanks a lot! it seems to work when i put it behind a button. However it does not work when i put it in a beforeupdate event. thanks alot for ur help :D
 
You were trying to create a unique number to act as your PK in the before update event (the event that fires when you change data that is already in your table)? Wouldn't you normally do that in the before insert event? Or did I miss something?
 
actually i tried in the before insert also.. then it had the same problem. so i thought maybe i was wrong and did it in the before update .. but still same problem :(
 
Wouldn't you normally do that in the before insert event? Or did I miss something?
You're right George, that was the event I asked the OP to put it in.

ds_8805: Could you zip, upload and post the db and I'll have a look.
 
hey vbaInet due to security reasons i cannot post this database here. but now i just used a button only instead. Thanks all the help :) really appreciate it!
 
helllo sorry for the late reply. yup not in the before_update. i put the code behind a button on click event. Thanks for all ur help :D
 
Glad to know you found your way round it. You're welcome :)
 

Users who are viewing this thread

Back
Top Bottom