Convert numbers to month names

Poppy

Registered User.
Local time
Today, 17:54
Joined
Feb 22, 2005
Messages
18
HI All

I am currently modifying a db for a user in access and am come accross two road blocks.

1.
I have included an extra (number)field in the db which allows the sorting of the db in the number order. What I want to do now and am finding difficult is: Every time the user adds a new record, the program must find the last record number and add 1 to this number. It must then assign this number to the extra field for the new record.


2. I initially displayed a datasheet view of the table to the user to allow editing and new additions, however because the table was linked to another table, it was causing poblems. I then decided to write a query to display the data. I now need to convert the month numbers to the month names in the query. Please throw me some ideas on how to go about this.

Thanx

Kind Regards
 
Poppy said:
1.
I have included an extra (number)field in the db which allows the sorting of the db in the number order. What I want to do now and am finding difficult is: Every time the user adds a new record, the program must find the last record number and add 1 to this number. It must then assign this number to the extra field for the new record.

Many people have this problem when creating their database and it would be in your best interest to search the forum for previous solutions.

I initially displayed a datasheet view of the table to the user to allow editing and new additions, however because the table was linked to another table, it was causing poblems. I then decided to write a query to display the data. I now need to convert the month numbers to the month names in the query.

Is the month number being stored on its own in a field? If so, why? Since you can't format a number to become text in this instance you can use a VBA function to perform the calculation.

Code:
Public Function GetMonthName(ByVal lngMonth As Long) As String
    On Error Goto Err_GetMonthName
    Dim dteTemp As Date
    If lngMonthName < 1 And lngMonthName > 12 Then
        GetMonthName = vbNullString
        Exit Function
    End If
    dteTemp = DateSerial(Year(Date), lngMonth, 1)
    GetMonthName = Format(dteTemp, "mmmm")
    Exit Function
Err_GetMonthName:
    GetMonthName = vbNullString
End Function
 
I have included an extra (number)field in the db which allows the sorting of the db in the number order. What I want to do now and am finding difficult is: Every time the user adds a new record, the program must find the last record number and add 1 to this number. It must then assign this number to the extra field for the new record.
Look up Autonumber in help, it is what it is for.

Peter
 

Users who are viewing this thread

Back
Top Bottom