in the design view for the form, right-click on the small square in the top left corner, and choose properties. pick the Event tab, pick the 'on open' field, click the three dots to the right of it, choose code builder, and paste that function in between the "Private......." and "End Sub".