Decimal point dissappears on form

B

Barry A&P

I have a form where the combo boxes are populated by various code. for some
reason the combo values in TSN and TSO end up being 12340 instead of the
actual result 1234.0

the Table fields are set to Decimal and i tried setting the combo formats
to everything in the book..

I would also appreciate any help with my D-lookup methods as it may not be
the best way i want all of my values to come from the record in T_Install
history where SNID equals my form combo with the Dmax Removal date i could
only figure out how to do it with a number of d-lookups rather than just one
where i dlook up the records ID then use that ID as criteria for my other
Dlookups can i use a dlookup to return 4 fields of the same record??..

Here is my code

Private Sub SerialNumberIDCombo_AfterUpdate()
'Set all my variables
Dim RmvDate As String
Dim InstallID As String
Dim InstallTSN As String
Dim InstallTSO As String
Dim InstallparentTT As String
Dim RemovalParentTT As String
Dim TotalTIS As String
Dim ParentSNID As String
Dim Remarks As String 'string to fill remarks area on tag
Dim Reason As String

'Clear some stuff and fill what i can

Me!NSN = Me!SerialNumberIDCombo.Column(1)
Me!PartNumber = Me!SerialNumberIDCombo.Column(2)
Me!Description = Me!SerialNumberIDCombo.Column(3)
Me!SerialNumber = Me!SerialNumberIDCombo.Column(4)
Remarks = Me!SerialNumberIDCombo.Column(5)
Me!RemovedFrom = ""
Me!AtTT = ""
Me!TSO = ""
Me!TSN = ""
Me!TagDate = Date


'quit if there is no removal date
RmvDate = Nz(DMax("[RemovalDate]", "T_installhistory", "SerialNumberID = " &
Me![SerialNumberIDCombo]), "#0#")
If RmvDate = "#0#" Then
MsgBox "No removal history found for this item..", , "No History
Available."
Me!SNNotes = Remarks
Exit Sub
End If

'show msg if the max removal date is less than the max install date
If DMax("[InstallDate]", "T_installhistory", "SerialNumberID = " &
Me![SerialNumberIDCombo]) >= RmvDate Then
MsgBox "My Records show a Installation date posted after this removal
date. This tag may not have the most current data.", , "Warning!! Is
Component Installed?"
End If

'If the dates are good lets fill out some more data
InstallID = DLookup("[installID]", "T_installhistory", "SerialNumberID = " &
Me![SerialNumberIDCombo] & " AND RemovalDate = #" & RmvDate & "#")
InstallTSN = Nz(DLookup("[installTSN]", "T_installhistory", "installID = " &
InstallID), "UNK")
InstallTSO = Nz(DLookup("[InstallTSO]", "T_installhistory", "installID = " &
InstallID), "UNK")
RemovalParentTT = Nz(DLookup("[RemovalParentTT]", "T_installhistory",
"installID = " & InstallID), "UNK")
InstallparentTT = Nz(DLookup("[InstallParentTT]", "T_installhistory",
"installID = " & InstallID), "UNK")
ParentSNID = Nz(DLookup("[ParentID]", "T_installhistory", "installID = " &
InstallID), "UNK")
Me!RemovedFrom = Nz(DLookup("[SerialNumber]", "T_Serialnumbers",
"SerialnumberID = " & ParentSNID), "UNK")
Me!AtTT = RemovalParentTT

'add a reason to our remarks string
If IsNull(DLookup("[ReasonForRemoval]", "T_installhistory", "installID =
" & InstallID)) Then
Remarks = "Removed: " & RmvDate & " " & Remarks
Else
Remarks = "Removed: " & RmvDate & " Reason: " &
DLookup("[ReasonForRemoval]", "T_installhistory", "installID = " & InstallID)
& " " & Remarks
End If

'We dont want to have bad data
If InstallparentTT = "UNK" Or RemovalParentTT = "UNK" Then
Me!SNNotes = Remarks
Exit Sub
End If

TotalTIS = RemovalParentTT - InstallparentTT
Me!AtTT = RemovalParentTT

'we also cant have a negative Time in service
If TotalTIS < 0 Then
Me!SNNotes = Remarks
Exit Sub
End If

If InstallTSO = "UNK" Then
Me!SNNotes = Remarks
Exit Sub
End If

Me!TSO = InstallTSO + TotalTIS

If InstallTSN = "UNK" Then
Me!SNNotes = Remarks
Exit Sub
End If

Me!TSN = InstallTSN + TotalTIS

'lets finally fill that remarks box
Me!SNNotes = Remarks
End Sub

Thanks

Barry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top