benjee
Personal Jesus
- Local time
- Today, 13:23
- Joined
- Mar 19, 2003
- Messages
- 53
Hello,
I'm having problems trying to increment the JobNo primary key when i want to create a new job. The code in comments is the code im working on.
The rest of the code is the procedure that kicks in when the Add Job is clicked from a customer details form (that appears prior to the Job Details form).
I want the Job number to increment automatically when this Add Job button is pressed (from the customer details screen).
regards
Private Sub AddJob_Click()
On Error GoTo Err_AddJob_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim JobnoID As Long
If IsNull(Me![Surname]) Then
MsgBox "Enter customer information before entering a job"
Else
'DisplayJob is a global variable defined in BasMisc
'and tested in frmJobSheet On Open
DisplayJob = False
stDocName = "frmJobSheet"
stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
/* DoCmd.GoToRecord , , acLast
JobnoID = JobNo
If JobnoID = 0 Then
JobNo = 1
Else
DoCmd.GoToRecord , , acNext
JobNo = JobnoID + 1
End If
*/ End If
Exit_AddJob_Click:
Exit Sub
Err_AddJob_Click:
MsgBox Err.Description
Resume Exit_AddJob_Click
End Sub
I'm having problems trying to increment the JobNo primary key when i want to create a new job. The code in comments is the code im working on.
The rest of the code is the procedure that kicks in when the Add Job is clicked from a customer details form (that appears prior to the Job Details form).
I want the Job number to increment automatically when this Add Job button is pressed (from the customer details screen).
regards
Private Sub AddJob_Click()
On Error GoTo Err_AddJob_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim JobnoID As Long
If IsNull(Me![Surname]) Then
MsgBox "Enter customer information before entering a job"
Else
'DisplayJob is a global variable defined in BasMisc
'and tested in frmJobSheet On Open
DisplayJob = False
stDocName = "frmJobSheet"
stLinkCriteria = "[CustomerID]=" & Me![CustomerID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
/* DoCmd.GoToRecord , , acLast
JobnoID = JobNo
If JobnoID = 0 Then
JobNo = 1
Else
DoCmd.GoToRecord , , acNext
JobNo = JobnoID + 1
End If
*/ End If
Exit_AddJob_Click:
Exit Sub
Err_AddJob_Click:
MsgBox Err.Description
Resume Exit_AddJob_Click
End Sub