Row navigation using previous and next button excel form vba -


i have excel form employee data entry work. excel sheet contains details of employees. want form navigate through each record through previous , next button, displaying content in form.

i written code not working properly. gives invalid record details while reaching begin , end of records. me

private sub userform_initialize() frmempdetails.combogender.additem "male", 0 frmempdetails.combogender.additem "female", 1 counter = activesheet.usedrange.rows.count temp_counter = counter lbltmpcount.caption = temp_counter end sub  private sub btnnext_click() status = 1 lbltmpcount.caption = temp_counter if (temp_counter >= counter)     msgbox "reached end" else     temp_counter = temp_counter + 1     txtid.text = cells(temp_counter, 1).value     txtname.text = cells(temp_counter, 2).value     txtdob.text = cells(temp_counter, 3).value     combogender.value = cells(temp_counter, 4).value     txtaboutemp.text = cells(temp_counter, 5).value     lbltmpcount.caption = temp_counter end if end sub  private sub btnprev_click() status = 1 lbltmpcount.caption = temp_counter if (temp_counter < 2)     msgbox "reached beginning" else     txtid.text = cells(temp_counter, 1).value     txtname.text = cells(temp_counter, 2).value     txtdob.text = cells(temp_counter, 3).value     combogender.value = cells(temp_counter, 4).value     txtaboutemp.text = cells(temp_counter, 5).value temp_counter = temp_counter - 1 end if end sub 

you can disable respective button once control reached end / beginning of file.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -