语法错误,缺少运算符 [英] syntax error, missing operator

查看:85
本文介绍了语法错误,缺少运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望加入并立即提出一个问题(特别是看似常见的问题)并不是一种糟糕的形式。我今天看了很长时间的代码,我无法弄清楚MS Access / VBA想要什么。我显然错过了一个运营商。非常感谢任何帮助。


调试时标记的片段是:

展开 | 选择 | 换行 | 行号

解决方案

FindFirst的典型用法假定您先前已填充记录集(使用 CurrentDB.Execute OpenRecordset )。填充记录集后,使用FindFirst获取记录集中符合您在参数中指定的条件的第一条记录。


传递给FindFirst的参数似乎具有这样的标准(" [ReportType] =& Report_Type" ),但是你跟着一个SQL字符串的片段(没有SELECT子句的SQL语句是不可能的,但是这个问题与此相去甚远。


你可以1)发布更多代码,以便我们可以在FindFirst调用之前看到你在做什么,以及2)解释你想用SQL片段完成什么?


Pat


这是字符串翻译后的样子。


给定PI_Number =''abc''

展开 | 选择 | Wrap | 行号


兔子,谢谢 - 我是VBA新手所以我还是混淆了那会产生的东西。


zepphead80,有趣的是,当我救了&关闭我的代码,然后关闭表单,然后重新打开表单并单击应该运行它的按钮,它(sortof)工作。给出了与我想要的相反的反应...


所以我有这个带有项目ID编号(PI_Number)的数据库,我想允许用户使用表格输入数据。问题是我的用户是在创建新条目之前不理解(手动)搜索数据库中的先前条目的典型人。


1不允许重复PI编号的问题是我们根据他们正在查看的报告类型有重复项。因此,没有两个PI +报告类型可以复制。我想允许用户输入PI编号和报告类型,并在他/她点击保存时运行代码。 (不是默认值 - 而是表单上的按钮),用于在数据库中查找PI NUmber +报告类型组合。如果组合已经存在,请给它们一个弹出消息,指出存在 - 要记录。然后他们点击确定然后继续如果组合不存在,那么用户就不会更聪明,并且会创建一个新条目。


对我来说这听起来很复杂......


无论如何......如果没有记录给出一个消息框(在允许保存之前进行测试),我的代码会跟随查找记录。

展开 | 选择 | Wrap | 行号< /跨度>

I hope it is not bad form to join and immediately ask a question (especially one that appears to be common). I have looked at my code so long today, that I cannot figure out what MS Access/VBA wants. I am apparently missing an operator. Any help is greatly appreciated.


The snippet flagged when I debug is:

Expand|Select|Wrap|Line Numbers

解决方案

The typical usage for FindFirst assumes that you previously populated the recordset (using say CurrentDB.Execute or OpenRecordset). Once the recordset is populated, you use FindFirst to grab the first record in the recordset that meets the criteria that you specify in the argument.

The argument that you pass to FindFirst appears to have such criteria ("[ReportType] = & Report_Type"), but then you follow it with a fragment of a SQL string (a SQL statement without a SELECT clause isn''t even possible, but that''s a little beside the point here).

Can you 1) post more code so that we can see what you''re doing prior to the FindFirst call, and 2) explain what you''re trying to accomplish with the SQL fragment?

Pat


Here''s what that string looks like once it''s translated.

Given PI_Number = ''abc''

Expand|Select|Wrap|Line Numbers


Rabbit, thanks - I am new to VBA so I was still muddling through what that would come out as.

zepphead80, Funny thing is that when I saved & closed my code, then closed the form, then reopened the form and clicked the button that''s supposed to run this, it (sortof) worked. Gave the opposite response than I wanted...

So I have this database with Project ID Numbers (PI_Number) and I want to allow users to use a form to enter data. Problem is my users are the typical person who doesn''t understand to (manually) search for previous entries in the database before creating a new entry.

1 problem with not allowing duplicate PI numbers is that we have duplicates based on what report type they are viewing. So no two PI + Report Type can duplicate. I want to allow user to enter a PI Number and Report Type and have code to run when s/he hits "save" (not the default - but a button on the form) that looks for the PI NUmber + Report Type combination in the database. If the combo already exists, give them a pop up message that states "exists - going to record" and they click ok and go. If the combo doesn''t exist, the user is none the wiser, and a new entry is created.

To me this sounds very convoluted...

Anyhow... my code follows for the find record if no record give a mesage box (testing before just allowing a save).

Expand|Select|Wrap|Line Numbers


这篇关于语法错误,缺少运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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