By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,985 Members | 2,877 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,985 IT Pros & Developers. It's quick & easy.

Default Value

P: 27
Can somebody tell me, what code shall I use whe I have a Purchase Order form and I want to set up a default Purchase order Number (field :PO NO) to start from 5563 . It needs to be amendable.
Thanks
Apr 10 '08 #1
Share this Question
Share on Google+
8 Replies


mshmyob
Expert 100+
P: 903
You could put it in the Default Value property but that would remain the same each time you created a PO which is probably not what you want.

What you need to do is look at your last PO # and increment by 1.

cheers,

Can somebody tell me, what code shall I use whe I have a Purchase Order form and I want to set up a default Purchase order Number (field :PO NO) to start from 5563 . It needs to be amendable.
Thanks
Apr 11 '08 #2

P: 27
yes I know, but is there any code I can use to run this option???
Apr 16 '08 #3

mshmyob
Expert 100+
P: 903
To change the default value of a text box.

Expand|Select|Wrap|Line Numbers
  1. Me.txtBox.DefaultValue = 60  ' change the value to anything you want
  2.  

I don't know if this is what you want but if the text box is bound to a field then when you add a new record the value of the bound text box will automatically have the default value.

For what you want to do this is not the recommended way especially if you are in a multi user environment.

cheers,

yes I know, but is there any code I can use to run this option???
Apr 16 '08 #4

missinglinq
Expert 2.5K+
P: 3,532
If your PO Number is Numerical, something like this should do the job:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If Me.NewRecord Then
  3.  If RecordsetClone.RecordCount = 0 Then
  4.   Me.POField = 5563
  5.  Else
  6.   Me.POField = DMax("POField", "MyTableName") + 1
  7.  End If
  8. End If
  9. End Sub
Welcome to bytes!

Linq ;0)>
Apr 16 '08 #5

mshmyob
Expert 100+
P: 903
No matter how you do it be very careful of a multiuser environment and being able to UNDO (cancel) your changes once a PO has been started.

cheers,
Apr 16 '08 #6

missinglinq
Expert 2.5K+
P: 3,532
mshmyob is correct! Whatever you decide to do should be in the Form BeforeUpdate event. This means that the number is assigned at the last second, which, in a multi-user environment, means there's less chance of duplication. It also means if you use Me.Undo to dump the record, the number will not have been assigned.

Linq ;0)>
Apr 16 '08 #7

P: 27
Hi!!!
I would like to thank you very very much,,,,,
you are really helpful guys:)
Apr 17 '08 #8

missinglinq
Expert 2.5K+
P: 3,532
That's why we're here!

Linq ;0)>
Apr 17 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.