Only the month required from the Date Field

Wong

Registered User.
Local time
Today, 11:17
Joined
Aug 17, 2005
Messages
14
Hello everyone

I am wanting to pull out only the month part from a date field, 11/10/2005.

In the query I have made an expression to pull the month, eg 10 for October.

I need to convert this number of the month to the Title of the Month.

I made a combo box on the report based on the Expression and in the row source put

1,"January", 2,"February",3, "March", 4,"Apri", 5,"May", 6,"June", 7,"July", 8,"August", 9, "September", 10, "October", 11, "November", 12, "December"

Unfortunately it still comes out with the number of the month.

Can anyone tell me please where I am going wrong.

Thank You in advance.
 
Hi -

For those using A97 (and thus having no MonthName() function), the following will produce a string for use as a combo-box's value list. It should work equally well in A2000 and later versions.
Code:
Function MonthLoop() As String
'creates a string to be used as a combo-box's value list
Dim datehold As Date
Dim strSQL   As String
Dim i        As Integer
Dim n        As Integer

    n = 12
    strSQL = ""
    
    For i = 1 To n
       datehold = DateSerial(Year(Date), i, 1)
       strSQL = strSQL & i & "," & Format(datehold, "mmmm") & ";"
    Next i
    
    MonthLoop = strSQL
    
End Function

HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom