动态更改表单上的记录源/控制源 [英] Dynamically change record source/control source on a form

查看:56
本文介绍了动态更改表单上的记录源/控制源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


使用Access 2003.


我正在尝试动态设置当前表单的记录源设置文本框的控制源以将数据输入到三个表中的一个。

我有一个表单(frmAddNewUser),它将用户添加到三个单独的表之一(tblDefsAFP,tblDefsMSU) ,tblDefsWF)基于从同一表单上的选项组中选择一个选项按钮。


我有一个文本框(txtNewUser),它接受用户的名字并拥有它由它下面的三个选项按钮之一设置的控制源。


因此,回顾一下,用户名是在文本框中输入的,其中一个选项按钮应该是选择,并根据选项按钮的选择,应确定表单的记录源,并确定文本框的控制源。


哦,一切都启动基于提交按钮。


现在它是ac删除所有内容,就像它正在工作一样,但输入文本框的名称不会出现在指定的表格/查询中。


这里是代码:

展开 | 选择 | Wrap | 行号

解决方案

我试图给你一些线索,希望它在某一点......


这部分项目的VBA代码:


Dim stLinkCriteria As String

... ............

stLinkCriteria =" [A_NUMBER] =" &安培; "" &安培; Me.txtSSN& "''"

DoCmd.OpenForm stDocName ,,, stLinkCriteria

.............

我有一个用于数据输入的文本字段,并使用stLinkCriteria确保表/子表格也自动记录用户刚刚数据委托的a_number ...


你好JJP ,


我不确定这会对我有所帮助。你试图在不同的帖子中发布你的代码吗?


其他人有什么想法吗?



嗨JJP,


我不确定这对我有帮助。您是否尝试在不同的帖子中发布代码?


其他人有什么想法吗?



不,这不是我的目的,我向您展示我的部分代码,为您提供一些使用stLinkCriteria获取动态结果的线索......


Hi everybody,

Using Access 2003.

I''m trying to dynamically set the record source for the current form and set the control source for a text box to input data to one of three tables.

I have a form (frmAddNewUser) that will add users to one of three separate tables (tblDefsAFP, tblDefsMSU, tblDefsWF) based on the selection of an option button from an option group on the same form.

I have a textbox (txtNewUser) that accepts the name of the user and will have it''s control source set by one of the three option buttons below it.

So, to recap, the user name is entered in a text box, one of the option buttons should be selected, and based on the selection of the option button, the record source for the form should be determined and the control source for the text box should be determined.

Oh, and everything launches based on a submit button.

Right now it accepts everything as if it''s working, but the name entered into the text box isn''t appearing in the table/query specified.

Here''s the code:

Expand|Select|Wrap|Line Numbers

解决方案

I am trying to give you some clue, hopefully it is at the point...

This part of my project''s VBA code:

Dim stLinkCriteria As String
...............
stLinkCriteria = "[A_NUMBER]=" & "''" & Me.txtSSN & "''"
DoCmd.OpenForm stDocName, , , stLinkCriteria
.............

I have a text field for use to data entry, and use stLinkCriteria to make sure table/subform also automatically recorded a_number that user just data entried...


Hi JJP,

I''m not sure that this helps me out. Were you trying to post your code in a different thread?

Anyone else have any ideas?


Hi JJP,

I''m not sure that this helps me out. Were you trying to post your code in a different thread?

Anyone else have any ideas?

No, that''s not my purpose, I show you part of my code to give you some clue to use the stLinkCriteria to get the dynamic result...


这篇关于动态更改表单上的记录源/控制源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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