antonyx
Arsenal Supporter
- Local time
- Today, 07:12
- Joined
- Jan 7, 2005
- Messages
- 556
i have a jobref (pk) as text at the moment because i tried it as Number data type and had a problem..
a reference number is made and when the date loses focus the refno is displayed in its textbox
this makes that refno
8 digits..
so a job on september 6th 2006 will have a ref no of 09060001
a job on february 1st 2006 will have ref no of 02060001
when i send the jobref to another form using this..
and the job_cash_inflight form loads it with this..
the problem is when i choose february the first for example
02060001.. when the reference number transfers to the incoming flight form.. it displays as 2060001
can anyone see why because before it transfers the refno.. the original job record has already been saved.. maybe when the id is being created it is not the best way.. or it doesnt match the text datatype.. if that is the case what number datatype shall i use in each of the tables jobref appears in?
a reference number is made and when the date loses focus the refno is displayed in its textbox
this makes that refno
Code:
Private Sub cbojobdate_LostFocus()
Dim maxRef As Variant, maxID As Integer
Dim codeDate As String, maxDate As String
codeDate = Format(cbojobdate, "MMYY")
maxRef = DMax("jobref", "job", "jobref like '" & codeDate & "*'")
If (IsNull(maxRef)) Then 'test for new month
maxID = 0 'reset id to 0
Else
maxDate = Left(maxRef, 4) 'get date code
maxID = CInt(Right(maxRef, 4)) 'convert to int
End If
Me.cbojobref = codeDate & Format(maxID + 1, "0000")
End Sub
8 digits..
so a job on september 6th 2006 will have a ref no of 09060001
a job on february 1st 2006 will have ref no of 02060001
when i send the jobref to another form using this..
Code:
Private Sub cbojobfrom_AfterUpdate()
If Me.cbojobfrom = "t1" Then
Me.cbojobfrom = "LHR - T1"
End If
If Me.cbojobfrom = "t2" Then
Me.cbojobfrom = "LHR - T2"
End If
If Me.cbojobfrom = "t3" Then
Me.cbojobfrom = "LHR - T3"
End If
If Me.cbojobfrom = "t4" Then
Me.cbojobfrom = "LHR - T4"
End If
If Me.cbojobfrom = "h" Then
Me.cbojobfrom = "LHR"
End If
If Me.cbojobfrom = "ga" Then
Me.cbojobfrom = "Gatwick Airport"
End If
If Me.cbojobfrom = "gn" Then
Me.cbojobfrom = "Gatwick North"
End If
If Me.cbojobfrom = "gs" Then
Me.cbojobfrom = "Gatwick South"
End If
If Me.cbojobfrom = "st" Then
Me.cbojobfrom = "Stansted"
End If
If Me.cbojobfrom = "lc" Then
Me.cbojobfrom = "London City Airport"
End If
If Me.cbojobfrom = "lu" Then
Me.cbojobfrom = "Luton Airport"
End If
DoCmd.OpenForm "job_cash_inflight", , , "[jobref]='" & [jobref] & "'"
End Sub
and the job_cash_inflight form loads it with this..
Code:
Private Sub Form_Open(Cancel As Integer)
Me.[jobref].DefaultValue = Forms!job_cash_single![jobref]
End Sub
the problem is when i choose february the first for example
02060001.. when the reference number transfers to the incoming flight form.. it displays as 2060001
can anyone see why because before it transfers the refno.. the original job record has already been saved.. maybe when the id is being created it is not the best way.. or it doesnt match the text datatype.. if that is the case what number datatype shall i use in each of the tables jobref appears in?