What is the other method to which you refer? Why have you set warnings
to false, and why have you not set them back to true? Why are you
opening a query? Why are you writing values from the current form (the
one on which Command15 is located) to frmOrderPlacement (I assume that's
what you are trying to do)? What is frmAccountCustomers, and why are
you closing it? Remember, only you can see your project, so code without
context, especially unconventional code, is difficult to decipher.
In short, what are you trying to do with the command button code?
What happens with the code in the Current event? In which form's
Current event is the code located?
Hi Bruce,
I have also found another method, which when I test with a simple form
and add a record it works, however, when I put it on my form, which is
opened from another form via :
Private Sub Command15_Click()
DoCmd.SetWarnings False
DoCmd.OpenQuery "TempCustomerPriceCheck"
DoCmd.OpenForm "frmOrderPlacement", acNormal, "", "", acFormAdd,
acWindowNormal
Forms!frmOrderPlacement!accountID = accountID '.Value
Forms!frmOrderPlacement!txtcustID = CustID '.Value
Forms!frmOrderPlacement!txtaddress1 = Address2 '.Value
Forms!frmOrderPlacement!txtaddress2 = Address1 '.Value
Forms!frmOrderPlacement!txtaddress3 = Address3 '.Value '
Forms!frmOrderPlacement!txtName = CustName '.Value
Forms!frmOrderPlacement!txtpostcode = Post_Code '.Value
DoCmd.Close acForm, "frmAccountCustomers"
Forms!frmOrderPlacement.SetFocus
End Sub
I have added this code to the onCurrent event:
If Me.NewRecord Then
Me!invoice.DefaultValue = Nz(DMax("[invoice]", "orders"), 0) + 1
End If
Me.refUser = GetUsrFullName
End Sub
Any suggestions would be appreciated.
Regards
Les
No idea without more information. Post the table structure, the
expression you are using to increment the number and where the
expession resides, and an explanation of the way in which it does not
work (error message, nothing at all, #Error in the text box, or
whatever).
Hi Bruce and thanks for that, However, I have tried this and not
having any sucess with this method, seems simple enough, but cannot
get it to work.
I am putting this code just as it is in the example and substituting
the field and table names for my own, any suggestions as to why this
would not work for me?
Regards
Les
This may be just what you need:
http://www.rogersaccesslibrary.com/download3.asp?SampleName=AutonumberProblem.mdb
Note that you can format the number if you want leading zeros. In
the text box Format property:
00000
will turn 1 in 00001; 101 will be 00101.
Hi Guys,
Looking for help with this issue. I have an invoice form with a
field [invoice_num] and want, on save, to create a sequential
number. If user cancels the record any point before save I do not
want to save the number to ensure sequence for invoices is
consistent.
Any suggestion would be most helpful.
TIA