MS Access VBA 问题 [英] MS Access VBA issue

查看:30
本文介绍了MS Access VBA 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 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 中附加查询时,它首先说 您将要附加查询,您确定吗"(或类似的东西),那么有没有办法自动化它,所以当我附加它时什么也没有发生?

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)

因此,只要我在收到 APPEND 进程的通知并输入 USER ID 的参数时按 OK、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

而且我意识到一旦我将值传递给表单(用户 ID),当我的查询被附加时,该值将作为参数传递.所以一切都准备好了.感谢大家的帮助!

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屋!

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