vba - Store MonthName() function in a string variable -


first question here go easy on me!

i new visual basic (but not programming) , having trouble on project working on local organization.

i have button runs query contains single "select ... ... " statement. statement looks every record field recievedboxtoday equal "yes". here code working fine:

select * rename_this_table [database zero] (([database zero].recievedboxtoday)=yes); 

now here problem (besides fact received spelled wrong): code ran every month, table (rename_this_table) over-written every time button clicked. have permanent data every month solution rename rename_this_table table monthname_year monthname name of month (january or december) , year current year (2015). thought go doing monthname() function, works fine, want able store month name string concatenated year (also string). afterwords string replace rename_this_table.

my code doesn't seem work is:

dim month string dim year string  monthname(month(date()), false) month year(date()) year  dim newname string = month + "_" + year 

after i'm not sure go far taking new string variable , inserting sql code, replace rename_this table.

how can make work? can make work? if matters, using vba microsoft access 2013. appreciated!

don't use month , year variable names. reserved (function) names in vba. also, shortcut, can use format() function format date string:

dim strnewname string strnewname = format(date, "mmmm_yyyy")    ' => "august_2015" 

if sql statement stored in separate string, can concatenate new table name string:

dim strsql string strsql = "select * " & strnewname & " [database zero] (([database zero].recievedboxtoday)=yes);" 

Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

php - How do you embed a video into a custom theme on WordPress? -