MS Access VBA问题 [英] MS Access VBA issue
问题描述
我正在MS Access中做一个报告-我在这里要做的基本上是将查询添加到我已经创建的表中-选择第一个值,更改它并更新该表.我遇到的问题是-该报告将由VB6应用程序使用.因此,用户根本不会看到Access.
I'm making a report in MS Access - what I'm trying to do here is basically APPEND a query to a table that I've already created - I select the first value, change it and update the table. The issue that I'm coming across is - this report will be used by a VB6 application. So the user won't be seeing Access at all.
我的附加查询的问题是它需要一个USER ID
来运行(4位数字).通常,当我在Access中运行报表时,我会将参数传递给Access中的表单-然后使用它们来运行查询.但是,在这种情况下,我需要用户在附加查询时输入一个值,此外,在VBA中附加查询时,它首先会说"You are about to append a query, are you sure"
(或类似的说法),因此有一种方法可以自动执行好吧,所以当我附加它时,什么都没有发生?
The thing with my append query is that it needs a USER ID
to run (4 digit number). Normally when I run a report in Access I pass the parameters to a form in Access - and I use them to run queries. However, in this case, I need the user to enter a value when appending the query, additionally, when appending a query in VBA it first says "You are about to append a query, are you sure"
(or something along those lines), so is there a way to automate that as well, so when I append it nothing happens?
这是我的代码,用于从tempTable
附加和选择日期:
Here is my code for appending and selecting date from the tempTable
:
CurrentDb.Execute "DELETE from [tempCompanyMgmt-NOW];"
DoCmd.OpenQuery "qryCompanyMgmt-SUE" - i made this append!
Set rs1 = CurrentDb.OpenRecordset("Select * from [tempCompanyMgmt-NOW]", , dbOpenDynamic)
只要我按OK,当我收到APPEND程序的通知并输入USER ID
的参数时,便是YES-一切正常.
So as long as I press OK, YES when I get notified of the APPEND process and enter the parameter for USER ID
- everything works fine.
推荐答案
要摆脱MsgBox的影响,我要追加一个查询,在打开追加查询之前,我将其包含在模块中.
To get rid of the MsgBox telling me I'm about to append a query i included this in my module before I open my append query..
DoCmd.SetWarnings False
我意识到,一旦将值传递给表单(userID),当附加查询时,该值就会作为参数传递.一切准备就绪.感谢所有帮助!
And I realized once I have the value passed to the form (userID), that value gets passed on as a parameter when my query gets appended. So it's all set. Thanks for all help!
这篇关于MS Access VBA问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!