Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select case problem

Status
Not open for further replies.

billheath

Technical User
Mar 17, 2000
299
US
help!! I am trying to convert numbers to a time format. I developed this in an earlier database and it worked perfectly. When i copied the module to the new database, it doesn't work.

The select case statement does not evaluate ptoperly. No matter what the value of enttime, Select Case will always go to the last (>1200) statement.

ans = MsgBox("AM?", vbYesNo)

If ans = 6 Then
'Check for length of entry (IE; under 24 is probably on the hour; 1015 is probably 10:15, etc.)



Select Case enttime
Case Is < 24
Realtime = enttime & ":" & 0
Case Is < 1000
Realtime = Left(enttime, 1) & ":" & Right(enttime, 2)
Case Is < 1200
Realtime = Left(enttime, 2) & ":" & Right(enttime, 2)
'Greater than 1159 handles special case for 12 oclock to 12:59
Case Is > 1159
Realtime = Left(enttime, 2) - 12 & ":" & Right(enttime, 2)
End Select

Else
'If not AM, it must be Pm
Select Case enttime
Case Is < 24
Realtime = enttime + 12 & ":" & 0
Case Is < 1000
Realtime = Left(enttime, 1) + 12 & ":" & Right(enttime, 2)
Case Is > 1000
Realtime = Left(enttime, 2) & ":" & Right(enttime, 2)

End Select

End If
 
What is the data type of enttime ?
If string you may try to replace this:
Select Case enttime
with this:
Select Case Val(enttime)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Sorry, read it wrong, thought the "ans" was not evaluating properly.
 
Thanks, The Val(Enttime) worked. I did not think of that because i didn't do it on the last DB and it workedf there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top