Some business questions require you to know the first or last item in a data collection. In this video, learn how to find the first or last value in a table field.
- [Instructor] When you enter data…into a table sequentially, you can use…the DFirst and DLast functions…to find the oldest value or the newest value…in a field.…And even if your data wasn't entered…sequentially, or at least in a time series,…you can still look at the first and last values…in a column.…I've opened the course database…and I'll press alt+F11 to move…to the Visual Basic Editor,…and then click insert, and module.…And here I have a code module where I can…create my subroutine.…
I'll go ahead and type sub and I'll call…it firstlast, because we're looking…for the first and last values,…followed by a pair of open…and closed parentheses,…because I'm not passing any arguments.…And then I'll press enter a number of times,…get the end sub line and some blank space.…I'll create two message boxes,…one for the first value and one for the last.…So I'll type msgbox, then DFirst,…which is the keyword for the first value,…followed by left parentheses.…
Now I need to provide two bits of information.…The first is the expression,…
- Working with macros
- Running a VBA procedure
- Debugging VBA code
- Defining variables, constants, and calculations
- Displaying a calculated result in a message box
- Repeating tasks with loops
- Manipulating database objects
- Adding, editing, and deleting records
- Looking up values in a table
- Automating processes with macros
Skill Level Advanced
What you should know1m 38s
1. Introduction to Visual Basic for Applications
2. Define Variables, Constants, and Calculations
3. Add Logic to Your VBA Code
4. Debug Your VBA Code
5. Manipulate Database Objects Using DoCmd
6. Read and Manipulate Table Data
7. Manipulate a Database Using the Application Object
8. Control Forms and Reports Using the Me Object
9. Automate Processes Using Macros
Next steps1m 7s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.