A
Ange Kappas
Hi,
I asked for help from a previous problem I had which Fred was so
kind to help, but I forgot to mention that the Table concerned was triggered
from a Button from another Form called ACCOUNTS SEARCH.
What I wanted to do is to add code to a Button "On Click" in the Form
ACCOUNTS SEARCH which would open the Table ACCOUNT NUMBER look at the last
record, add a new record which is the next number. The ACCOUNT NUMBER Table
has ONLY one field called ACCOUNT NUMBER.
Hence if the last number was let's say "4" I want to add a new record
automatically being "5".
The code Fred gave me was:
Dim strSQL As String
strSQL = "Insert into ACCOUNT NUMBER([Account Number]) values (" &
DMax("[Account Number]", "ACCOUNT NUMBER") + 1 & ");"
CurrentDb.Execute strSQL, dbFailOnError
The Copy Paste of the code is as follows:
Private Sub ACCOUNTS_CHARGE_Click()
Dim strSQL As String
strSQL = "Insert into ACCOUNT NUMBER([Account Number]) values (" &
DMax("[Account Number]", "ACCOUNT NUMBER") + 1 & ");"
CurrentDb.Execute strSQL, dbFailOnError
DoCmd.OpenQuery "ACCOUNTS TRIGGER"
End Sub
Which gives me an error on the:
CurrentDb.Execute strSQL, dbFailOnError
Line
Hope someone can tell me where it is wrong !
Thanks
Ange
I asked for help from a previous problem I had which Fred was so
kind to help, but I forgot to mention that the Table concerned was triggered
from a Button from another Form called ACCOUNTS SEARCH.
What I wanted to do is to add code to a Button "On Click" in the Form
ACCOUNTS SEARCH which would open the Table ACCOUNT NUMBER look at the last
record, add a new record which is the next number. The ACCOUNT NUMBER Table
has ONLY one field called ACCOUNT NUMBER.
Hence if the last number was let's say "4" I want to add a new record
automatically being "5".
The code Fred gave me was:
Dim strSQL As String
strSQL = "Insert into ACCOUNT NUMBER([Account Number]) values (" &
DMax("[Account Number]", "ACCOUNT NUMBER") + 1 & ");"
CurrentDb.Execute strSQL, dbFailOnError
The Copy Paste of the code is as follows:
Private Sub ACCOUNTS_CHARGE_Click()
Dim strSQL As String
strSQL = "Insert into ACCOUNT NUMBER([Account Number]) values (" &
DMax("[Account Number]", "ACCOUNT NUMBER") + 1 & ");"
CurrentDb.Execute strSQL, dbFailOnError
DoCmd.OpenQuery "ACCOUNTS TRIGGER"
End Sub
Which gives me an error on the:
CurrentDb.Execute strSQL, dbFailOnError
Line
Hope someone can tell me where it is wrong !
Thanks
Ange