其中,用户名是从列表中选择MS Access窗体 [英] MS Access Form where user name is selected from list

查看:153
本文介绍了其中,用户名是从列表中选择MS Access窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要改写一个previous问题,我已经贴:

I am going to rephrase a previous question that I had posted:

我已经建立了访问的形式,可以让用户通过活动的工作时间进入(例如事务处理,项目时间,休假等)。表格中的字段有:

I have built a form in access that allows users to enter in their hours worked by activity (i.e. transactional processing, project time, vacation etc.). The fields on the form are:

1)用户名 2)开始日期 3)结束日期 4)活动 5)所花时间

1) user name 2) start date 3) end date 4) activity 5) hours spent

有没有办法让这种形式以这样的方式,当它打开了一个用户,提示会自动出现,迫使你的用户列表中选择用户名?不止一次的用户名被选中,通过这样的形式输入的所有记录都已经填充(除非该窗体关闭并重新打开一次)的用户名字段?

Is there a way to have this form in such a way that when it is opened up by a user, a prompt automatically appears that forces you to select the user name from a list of users? Than once the user name is selected, all records entered through this form have the user name field already populated (unless the form is closed and reopened again)?

根据提示中的用户名选择,使用previous记录和下一条箭头应严格与选定用户名的记录反复选择。

Based on the user name selection in the prompt, the toggling of records using the "Previous Record" and "Next Record" arrows should strictly pertain to the selected user name selected.

**这是我目前的形式**

** this is my current form**

用于生产下面提到的解决方案步骤

1)删除组合框被称为用户名
2)添加未绑定隐藏的文本框,并把它称为txUN
3)添加VBA code加载低于但改变了txtusername参考USER_FULL_NAME,因为这是在表中的列应存储这些记录的名称
4)创建下面的用户名组合框的形式,并把它称为cbousername
5)改变frm_sample参考[专家 - 时间表输入]

1) delete the combo box called "User Name"
2) add an unbound hidden text box and call it txUN
3) add the VBA code loaded below but changed the txtusername reference to user_full_name as this is the name of the column in the table that should store these records
4) created the form below with a combo box for user names and called it cbousername
5) change the frm_sample reference to [Specialist - Timesheet Entry]

推荐答案

选项,打开用户名的形式第一:

名为隐藏的文本框创建像下面的表单 txtUN

Create a form like the below with a hidden textbox named txtUN.:

通过以​​下$ C $落后C:

With the following code behind:

Private Sub Form_Current()
  If VBA.Strings.Len(txtUN & "") = 0 Then DoCmd.OpenForm "frm_UserName", acNormal, , , , acDialog
  If VBA.Strings.Len(txtUsername & "") = 0 Then txtUsername = txtUN
End Sub 

然后创建一个表像之下。命名下拉 cboUserName

通过以​​下$ C $落后C:

With the following code behind:

Private Sub cboUserName_AfterUpdate()
   Forms!frm_Sample.txtUN = cboUserName
End Sub
Private Sub Form_Unload(Cancel As Integer)
  If (VBA.Strings.Len(cboUserName & "") = 0) Then
     MsgBox "You must supply a user name before proceeding.", , "ERROR: Missing Info."
     Cancel = True
  End If
End Sub

当您打开 frm_Sample 它会检查,看看是否 txtUN 的值。如果没有它会打开 frm_UserName 作为一个对话框。用户必须选择一个用户名,并关闭对话框。当浏览到其他记录,如果 txtUsername 为空,那么它被分配任何 txtUN 包含的内容。

When you open frm_Sample it will check to see if txtUN has a value. If not it will open frm_UserName as a dialog. The user must select a user name and close the form. When navigating to another record if txtUsername is empty then it is assigned whatever txtUN contains.

这篇关于其中,用户名是从列表中选择MS Access窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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