vba - Using a Converted string in CurrentDB.Execute or DoCmd.RunSQL? -
table school year
has (in order):
id
primary key
description
short text in format of xxxx-xxxx
current year
boolean (only 1 checked @ time)
i'm creating button appends new year cycle table increasing year one. ex: 2009-2010 -> 2010-2011
however, current code, i'm doing string int conversion , string it's not staying back. table appends new data fine, data wrong. id
, current year
accurate, description
mathematical calculation , becomes -1
. (as in 2010-2011 = -1). however! msgbox display displays full year string.
how go fixing issue? in advance.
here's code:
private sub newyear_click() dim iyear integer dim sdesc string dim idesc1 integer dim idesc2 integer iyear = dcount("id", "school year") 'row count primary id number sdesc = dlookup("description", "school year", "[id] =" & iyear) 'grabbing string idesc1 = cint(right$(left(sdesc, 4), 4)) + 1 'increasing year 1 idesc2 = cint(right$(right(sdesc, 4), 4)) + 1 sdesc = idesc1 & "-" & idesc2 currentdb.execute "update [school year] set [current year] = false" 'turning off current year dim teststring string 'did in hope fix problem, didn't teststring = "insert [school year] values (" & iyear + 1 & ", " & sdesc & ", true)" currentdb.execute teststring msgbox "school year set " & sdesc end sub
Comments
Post a Comment