I have managed to write some pretty terrible code in VBA and I know there has to be a better way. I have made all of these variables to store some data which I eventually reference in the application. I'm fairly certain I need to loop over the recordset or fields and store the variables that way but I can't figure out how to do it in a way that actually simplifies this code. It's torturing me because it seems like a painfully simple concept.
The columns of the table that it is gathering data from looks similar to this:
[LANGUAGE_ID]-[NEXT]-[PREVIOUS]-[RESUME] -- and so on
sqlstmt = "SELECT *" & _
" FROM cf_Language" & _
" WHERE LANGUAGE_ID = " & parm_language & ";"
Set rst_t = dbs.OpenRecordset(sqlstmt, dbOpenSnapshot)
If (parm_language <> 1) Then
parm_surveyname = UnicodeToAscii(parm_surveyname, True)
aNext = UnicodeToAscii(rst_t![Next], True)
aPrevious = UnicodeToAscii(rst_t![previous], True)
aResume = UnicodeToAscii(rst_t![resume], True)
aFinish = UnicodeToAscii(rst_t![finish], True)
aSave = UnicodeToAscii(rst_t![Save], True)
aLogIn = UnicodeToAscii(rst_t![log_in], True)
aComplete = UnicodeToAscii(rst_t![complete], True)
aHeader = UnicodeToAscii(rst_t![header], True)
aThanks = UnicodeToAscii(rst_t![thanks], True)
aSavedMsg = UnicodeToAscii(rst_t![saved_msg], True)
aBlankCode = UnicodeToAscii(rst_t![blank_code], True)
aInvalidCode = UnicodeToAscii(rst_t![invalid_code], True)
aTimeOut = UnicodeToAscii(rst_t![timeout], True)
aClosed = UnicodeToAscii(rst_t![closed], True)
aAccessCode = UnicodeToAscii(rst_t![access_code], True)
aConFirstTime = UnicodeToAscii(rst_t![con_first_time], True)
aAnonFirstTime = UnicodeToAscii(rst_t![anon_first_time], True)
aAnonResume = UnicodeToAscii(rst_t![anon_resume], True)
Else
aNext = rst_t![Next]
aPrevious = rst_t![previous]
aResume = rst_t![resume]
aFinish = rst_t![finish]
aSave = rst_t![Save]
aLogIn = rst_t![log_in]
aComplete = rst_t![complete]
aHeader = rst_t![header]
aThanks = rst_t![thanks]
aSavedMsg = rst_t![saved_msg]
aBlankCode = rst_t![blank_code]
aInvalidCode = rst_t![invalid_code]
aTimeOut = rst_t![timeout]
aClosed = rst_t![closed]
aAccessCode = rst_t![access_code]
aConFirstTime = rst_t![con_first_time]
aAnonFirstTime = rst_t![anon_first_time]
aAnonResume = rst_t![anon_resume]
End If