How to iterate over table in Access 2010 -


i iterate on rows in payment table. user chose month , year has wants book , want check in each raw if house booked year , month. want compare if

houseid == chosenhouseid && bookingmonth == chosenbookingmonth &&      bookingyear==chosenbookingyear. 

if true should pop out message box info house booked month. if user chose more 1 month i.e. nummonths 3, should increment value of month (which text) should go next value (if there no next value should mod 12) , checking again. maybe necessary switch data type of bookingmonth numeric?

however hope clear want do. have experience java, c, python , visual basic, did not in access quite confusing. not find useful info how perform operation. please advise me on issue.

thank you

yes, should store [bookingmonth] numeric. maintaining "month" column text nuisance in long run, since "august"<"january" , "12"<"2". you'd have @ least amount of juggling convert text values numeric values, make easy , maintain them numeric. (note can format them text if want use them in reports.)

as search requirements, if user supplies [chosenbookingyear], [chosenbookingmonth], , [numberofmonthstobook] can use vba dateadd function derive [endofbookingyear] , [endofbookingmonth] safely, accounting "next year" values...

endofbookingyear = year(dateadd("m", numberofmonthstobook - 1, dateserial(chosenbookingyear, chosenbookingmonth, 1))) 

...and...

endofbookingmonth = month(dateadd("m", numberofmonthstobook - 1, dateserial(chosenbookingyear, chosenbookingmonth, 1))) 

finally, perform lookup without looping through individual rows can concatenate [bookingyear] , [bookingmonth] create "2013/05" using...

bookingyear & "/" & format(bookingmonth, "00") 

...so can create select query this:

select * payment houseid = chosenhouseid ,     (         (bookingyear & "/" & format(bookingmonth, "00"))             between (chosenbookingyear & "/" & format(chosenbookingmonth, "00"))                 , (endofbookingyear & "/" & format(endofbookingmonth, "00"))     ) 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -