Hi All
What I am trying to achieve is to ask a user for a month number via inputbox and then use this value in update queries - see the below piece of code.
The problem is that I would like ask user once at the beginning and re-use the value provided. However inputbox is called each time 'monthNumber' is used within SQL statement.
How could I solve it? I wouldn't like to use a form as this is the only value required from the user to input. Also I can't use a month() function instead of input box.
Thank you.
Sub updTables()
monthNumber = CInt(InputBox("Enter the month number:"))
DoCmd.RunSQL "UPDATE tblTexDataArchive SET tblTexDataArchive.Month_name = Monthname(monthNumber), tblTexDataArchive.Month_no = monthNumber, tblTexDataArchive.Year_no = Year(Date());"
'subsequent updates
DoCmd.RunSQL "UPDATE"
DoCmd.RunSQL "UPDATE"
End Sub
What I am trying to achieve is to ask a user for a month number via inputbox and then use this value in update queries - see the below piece of code.
The problem is that I would like ask user once at the beginning and re-use the value provided. However inputbox is called each time 'monthNumber' is used within SQL statement.
How could I solve it? I wouldn't like to use a form as this is the only value required from the user to input. Also I can't use a month() function instead of input box.
Thank you.
Sub updTables()
monthNumber = CInt(InputBox("Enter the month number:"))
DoCmd.RunSQL "UPDATE tblTexDataArchive SET tblTexDataArchive.Month_name = Monthname(monthNumber), tblTexDataArchive.Month_no = monthNumber, tblTexDataArchive.Year_no = Year(Date());"
'subsequent updates
DoCmd.RunSQL "UPDATE"
DoCmd.RunSQL "UPDATE"
End Sub