How to Use Browse To in VB and Macro
In this how to I will show to use Browse To command in both VB and Macro. The word “Browse” means “To look at or through something to see what is there” per Cambridge Dictionary. In MS Access, we use Browse To to jump from one form to another form. In this How To, I will show how to use Browse To to jump from the Alert Form to the second tab of Navigation Form. We have a tab of task due in 5 days on the second tab of Navigation Form. After the Task Due Alert message form opened we can click on the link on this form to go directly to see the list of task due in 5 days on the Navigation Form.
Follow the Step below on How to Use Browse To:
Step #1 Create Task Due Alert Form
I will use the Task Due Alert form to add a link to navigate to the second tab (Task Due in 5 days). See How to Create a Pop-Up Message before Task Due for more information about creating the alert message below. I will this form to add a link to open the Navigation Form and navigate to the second tab.
Step #2 Create Navigation Form
Create a simple Navigation Form as shown in the picture. I have four tabs starting from All Tasks, Task Due in 5 days, Over Due List, and Exit. I have a “Task Due in 5 Days” tab links to a data sheet form “TaskDuein5Days_DS.”
Step #3 Add a Link on Task Due Alert Form
- Change the second line of text label to “Click here to view the list”
- Double-Click on this line to bring up the Property Sheet
- Select “Event Procedure”
- Add VB code below to close the current form and browse to the Navigation Form
Private Sub Label3_Click() DoCmd.Close acForm, "Task Due Alert" Forms("navigation form").SetFocus DoCmd.BrowseTo acBrowseToForm, "TaskDuein5Days_DS", "Navigation Form.NavigationSubForm", , , acFormEdit End Sub
Step #4 Complete-Testing
After we completed the Navigation Form and Task Due Alert form, the Task Due Alert form will pop- up if we have tasks which will due in 5 days. When the Navigation Form is loaded, it will always browse to the first tab (All Tasks). Click on the link label “Click here to view the list.” The Task Due Alert form will close and the Navigation Form will browse to the second tab “Task Due in 5 Days” to show the list of tasks due in 5 days as shown in the picture below.
Note: Form must be opened in order to use browse to that form. In this example, if the Navigation Form is not opened you will get a message that cannot find the referenced form “Navigation Form” as shown below.
Use Browse To in Macro
If we don’t use VB code we can use the Browse To code in Macro. A line of code processing is the same as VB starting from close the Task Due Alert form and browse to the Navigation Form. It browses to a TaskDuein5Days_DS datasheet form in the Navigation Form tab. The path is Navigation Form.NavigationSubForm same as on VB.
Note: the code above will work when the Task Due Alert form is popped up by timer after the Navigation Form is loaded. For another reason, if you manually open the Task Due Alert form you may get the error message shown below due to the Navigation Form is not a focus form.
So you may add code to open the Navigation Form again on Macro before to use Browse To as shown below. By this way, the you set a focus to the Navigation Form then browse to the second tab.