Navigate a Recordset With a Userform – Part IV

The grand finale! In Part I, we set up the userform. Part II was special purpose procedures to make our coding a little easier down the line. Then in Part III, we connected to the Recordset. Now, we’ll code the four CommandButtons that will allow the user to navigate through the Recordset.

I told you this would be easy, and I wasn’t kidding. There are basically two kinds of buttons from a code perspective; buttons that take you to the extremes of the Recordset, and buttons that move one record at a time. All four buttons do three things; make the correct record the current record, call the FillTextBoxes sub, and call the DisableButtons sub. The “move one record” buttons have one additional step. Namely, to determine which record is current. If it’s the first or last record, we need different buttons disabled.

The methods MoveNext, MoveFirst, MovePrevious, and MoveLast are methods of the Recordset object. They couldn’t have made it much easier for us. The rest is just calling our procedures that do all the work.

You can download the file ADOInUserform.xls to see how it all fits together.

5 thoughts on “Navigate a Recordset With a Userform – Part IV

  1. Hello, looking for examples I came across this yours, but since I do not speak much English I find it a bit difficult to follow the example, your download link does not work, could you send me the file to my email please? Thank you.

    Atte.
    Carlos Soto
    caso601@yahoo.com

  2. Thank you very much, Dick Kusleika… it took me quite a while to find this and I’m sure it will save me a lot of time. I’ve programmed quite a lot in Excel VBA (building actuarial tools) but without much ADODB experience where data has to be written back to the database – usually I’ve just had to fetch data from a database, analyse it, and use the results.
    John


Posting code? Use <pre> tags for VBA and <code> tags for inline.

Leave a Reply

Your email address will not be published.