George10988
Registered User.
- Local time
- Today, 02:57
- Joined
- Apr 23, 2011
- Messages
- 41
Hey guys, I am trying to call a function that I made when a form is opened. I then want the function return value to populate into a textbox on that form. I know this is very simple because I know C#; however, I am new to VBA and I just cant seem to get this to work.
Basically I am trying to autopopulate a "Month" text box on a report with the current month. I originally used Month(Now()) and got an integer back; however, I want to return a string with the actual name of the month. This is what I have so far
'This is in my general declarations of the report
'Then I have this on the open event
Any help would be much appreciated
Basically I am trying to autopopulate a "Month" text box on a report with the current month. I originally used Month(Now()) and got an integer back; however, I want to return a string with the actual name of the month. This is what I have so far
'This is in my general declarations of the report
Code:
Public Function GetMonth(MonthName) As String
'This function will convert the returned month int to a string with the name of the month
'-----------------------------
'---------
'Author- George Campos
'Date- 5/6/2011
'Company- Accutron Systems
'-----------------------------
'---------
Dim ReturnMonth As Integer
Static MonthName As String
ReturnMonth = Month(Now())
Select Case ReturnMonth
Case 1
MonthName = "January"
Case 2
MonthName = "February"
Case 3
MonthName = "March"
Case 4
MonthName = "April"
Case 5
MonthName = "May"
Case 6
MonthName = "June"
Case 7
MonthName = "July"
Case 8
MonthName = "August"
Case 9
MonthName = "September"
Case 10
MonthName = "October"
Case 11
MonthName = "November"
Case 12
MonthName = "December"
End Select
End Function
'Then I have this on the open event
Code:
Private Sub Report_Open(Cancel As Integer)
Call GetMonth
Me.txtRptReportMonth = MonthName
End Sub
Any help would be much appreciated