MS Access VBA - system crashing during do until loop -
i'm trying calculate number of days between 2 dates on form, excluding weekends. however, system keeps crashing every time runs until loop. can spot might going wrong within code below?
thanks help!
private sub total_text_click() dim v_weekendcount integer dim v_date date dim dateone date dim datetwo date v_date = me.startdate_text.value v_weekendcount = 0 until v_date = me.enddate_text.value if day(v_date) = vbsaturday or day(v_date) = vbsunday v_weekendcount = v_weekendcount + 1 v_date = v_date + 1 end if loop dateone = me.startdate_text.value datetwo = me.enddate_text.value me.total_text.value = datediff("d", dateone, datetwo) - v_weekendcount end sub
you had in mind:
do until v_date = datevalue(me.enddate_text.value) if weekday(v_date) = vbsaturday or weekday(v_date) = vbsunday v_weekendcount = v_weekendcount + 1 end if v_date = v_date + 1 loop
Comments
Post a Comment