use this code:I need to populate the Month Name based on a date field in my table.
Thanks!!
format(DateFieldHere, "mmm")
no...update your table when you need. use the docmd.runsql command in VBA to do it.Do I put this in the table or the form? I need to have this data logged into a table based on a date field that is entered by a user, it wouldn't be a form field on the Form. Just for reporting etc...
Does that go into the Format under the General Tab in the Table Design ?
=format([FieldToFormat, "mmm")
upload your db and i'll do it real quickthat didn't work.
This should be simple like excel , take a date and turn it into a month. Sometimes I hate access...
Not sure even how to start coding this up in VB. I am sure its simple but not knowing much makes it hard.
I dont have 07 on my desktop, although i do have 8gb of RAM.I just made a simple form. Date field and a Month field.
Thanks a bunch!!
try the button now...Here it is. Thanks again.
.............If you have the date field in the table, you don't need to update the table, just use a query with the format displayed how you want it.
replace this:If I want the button to update without adding in the Table Name, since it will be the same table each time, how can I just make it run without entering in the table name?
mytable = InputBox("enter the table name")
Thanks,
Private Sub Command7_Click()
Dim mytable As String
mytable = InputBox("enter the table name")
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE [" & mytable & "] SET [monthmain] = month([datemain])"
DoCmd.SetWarnings True
End Sub
Private Sub Command7_Click()
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE [B][U]TABLENAMEHERE[/U][/B] SET [monthmain] = month([datemain])"
DoCmd.SetWarnings True
End Sub
replace this:with this:Code:Private Sub Command7_Click() Dim mytable As String mytable = InputBox("enter the table name") DoCmd.SetWarnings False DoCmd.RunSQL "UPDATE [" & mytable & "] SET [monthmain] = month([datemain])" DoCmd.SetWarnings True End SubCode:Private Sub Command7_Click() DoCmd.SetWarnings False DoCmd.RunSQL "UPDATE [B][U]TABLENAMEHERE[/U][/B] SET [monthmain] = month([datemain])" DoCmd.SetWarnings True End Sub
Just look at the Date format options. It's really very simple. No need to store redundant data as already has been pointed out. Just extract the month name when you need it..............![]()