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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change the format of Text (a string) 1

Status
Not open for further replies.

5tr0ud

Programmer
Aug 9, 2004
29
US
I have a string [FirstSem] of "20041" (first semester of 2004) which I want to format to be more of a date field (8/2004). Likewise, "20042" I would like to format to 1/2005. Here's pseudocode that may explain what I'm trying to do.

If (Mod(FirstSem, 10)=1, "8/" & Round([FirstSem]/10,
If (Mod(FirstSem, 10)=2, "1/" & Round ([FirstSem]/10, ""))

Can anyone provide some assistance with this -- does anyone know any better VBA coding for this? Thanks for whatever suggestion you may have.

 
Semester 1 always starts in August, and 2 always in January of the folling year? If so, try

if Right([MyField], 1) = 1 then
MyVal = "8/" & left ([MyField], 4)
else
Myval = "1/" & (val (left ([MyField], 4) + 1)
End if

ChaZ
 
I had to slightly modify your code -- (Me.[MyField]) and create another variable to pass in to field in the Main Form, but IT WORKED! I am truly appreciative, since it will be the basis of modifying the format of strings in the future. Again, THANK YOU!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top