J
JLF
I've been on other forum sites and have gotten some very viable solutions.
However, my last solution did not pass by management in creating a ticket no
that is to be pulled from a separate table and update each time the unique
number is used.
This is the code they did not like:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!HelpdeskTicketNo = Nz(DMax("[HelpdeskTicketNo]", "[Help Desk Tickets]")) +
1
Me.HelpdeskTicketNo.Requery
End Sub
It keeps jumping back to the first record and they do not want the Help Desk
Tickets table to be the table from which to pull the autonumber from. Here
is an alternative I am working on for the autonumber to come from a table
called tblNextNum, but it is not updating that table each time a record is
added and now it is not even showing a ticket number on the form:
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim db As DAO.Database
Dim rst As DAO.Recordset
If IsNull(Me![HelpdeskTicketNo]) Then
Set db = CurrentDb
Set rst = db.OpenRecordset("tblNextNum")
rst.MoveFirst
Me![HelpdeskTicketNo] = (rst![nextnum])
rst.Edit
rst![tblNextNum.nextnum] = rst![tblNextNum.nextnum] + 1
rst.Update
rst.Close
End If
End Sub
Any suggestions is greatly appreciated and I apologize in advance for posting
this issue once too many.
Thanks,
JLF
However, my last solution did not pass by management in creating a ticket no
that is to be pulled from a separate table and update each time the unique
number is used.
This is the code they did not like:
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!HelpdeskTicketNo = Nz(DMax("[HelpdeskTicketNo]", "[Help Desk Tickets]")) +
1
Me.HelpdeskTicketNo.Requery
End Sub
It keeps jumping back to the first record and they do not want the Help Desk
Tickets table to be the table from which to pull the autonumber from. Here
is an alternative I am working on for the autonumber to come from a table
called tblNextNum, but it is not updating that table each time a record is
added and now it is not even showing a ticket number on the form:
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim db As DAO.Database
Dim rst As DAO.Recordset
If IsNull(Me![HelpdeskTicketNo]) Then
Set db = CurrentDb
Set rst = db.OpenRecordset("tblNextNum")
rst.MoveFirst
Me![HelpdeskTicketNo] = (rst![nextnum])
rst.Edit
rst![tblNextNum.nextnum] = rst![tblNextNum.nextnum] + 1
rst.Update
rst.Close
End If
End Sub
Any suggestions is greatly appreciated and I apologize in advance for posting
this issue once too many.
Thanks,
JLF