使用 VBA 在不同表单上的选项卡控件上打开特定页面的 Access 表单 [英] Open Access form to a specific page on a tab control on a different form with VBA

查看:60
本文介绍了使用 VBA 在不同表单上的选项卡控件上打开特定页面的 Access 表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 60 页的选项卡控件上创建了帮助索引.每个页面都包含与该页面对应的问题的有用信息.正在回答的问题与选项卡控件表单位于不同的表单中.我在每个问题旁边创建了一个按钮,以便用户在需要完成每个问题的背景和说明时可以访问帮助表单.我正在尝试编写代码来打开表单并根据单击的按钮转到正确的页面.所以第一个问题的按钮将打开表单并转到第 1 页.我尝试了一些不同的方法,但无法识别该页面.以下是我目前拥有的代码:

I have created a help index on a tab control with 60 pages. Each page contains helpful information to the question that corresponds to the page. The questions that are being answered are on a different form from the tab control form. I have created a button next to each question so that the user can access the help form if they need background and instructions for completing each question. I am trying to write code that will open the form and go to the correct page based on the button that was clicked. So the button for question one would open the form and go to page 1. I have tried a few different things, and can't get it to recognize the page. Below is the code that I currently have in place:

DoCmd.OpenForm "frmTestingHelp"
Forms!frmTestingHelp.SetFocus
DoCmd.GotoPage (0)

表单打开,但找不到页面并导致错误.我开始时没有使用第二行,但添加了它以查看问题是否在于它没有在正确的位置寻找对象.
提前致谢!

The form opens, but cannot find the page and results in an error. I started without the second line, but added it to see if the issue was that it wasn't looking for the object in the right place.
Thanks in advance!

推荐答案

DoCmd.GotoPage 仅用于分页符,几乎没有人使用.见例如在这里:http://www.functionx.com/vbaccess/Lesson13.htm 和向下滚动到使用表单页面".

DoCmd.GotoPage is used only with page breaks, which hardly anybody uses. See e.g. here: http://www.functionx.com/vbaccess/Lesson13.htm and scroll down to "Using the Pages of a Form".

要选择表单上标签控件第二页 TabControl:

Forms!frmTestingHelp!TabControl.Pages(1).SetFocus

或者最好,如果您不想设置焦点,

or preferably, if you don't want to set the focus,

Forms!frmTestingHelp!TabControl.Value = 1

假设您没有更改默认的 PageIndex 值 0,1,...

assuming you haven't changed the default PageIndex values 0,1,...

这篇关于使用 VBA 在不同表单上的选项卡控件上打开特定页面的 Access 表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆