将select语句中的值赋给变量 [英] assigning the value from a select statement to a variable

查看:142
本文介绍了将select语句中的值赋给变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我实际上是在尝试从流量表的pre_05_growth_factor列中提取一个值,并将其分配给稍后要使用的变量。


有谁知道为什么下面的代码返回增长为0当我将此代码作为表单上按钮的单击事件的一部分运行但是如果我隔离Select语句并在SQL View中使用它创建查询然后运行它我从表中显示正确的结果?这告诉我我的语法是正确的,为什么我不能将select查询中的值赋给变量?感谢您的帮助。

展开 | 选择 | Wrap | 行号

解决方案

该SQL语句不存在执行任何地方您正在使用该字符串的Val()。


谢谢筹码。所以你是说我的SQL没有被执行?使用查询值执行和填充变量的正确格式是什么?我很感谢你花时间帮我解决这个问题。我以为我正确地构建了这个,但显然我不是。


通常我使用 DLookup 获取值并将其存储在控件或字符串中。我不确定你是否能够在DLookup的where条件中嵌套所有这些,或者你是否必须使用多个,或者只是基于查询,这取决于你必须运行多少次

Hi All,

I''m essentially trying to extract a value from the pre_05_growth_factor column of my traffic table and assign it to a variable to be used later.

Does anyone know why the code below returns "The growth is 0" when I run this code as part of an on-click event of a button on a form but if I isolate the Select statement and create a query with it in SQL View and then run it I get the correct result showing up from my table? This tells me my syntax is correct so why can I not assign the value from a select query to a variable? Thanks for any and all help.

Expand|Select|Wrap|Line Numbers

解决方案

That SQL statement is not being executed anywhere. You are taking the Val() of that string.


Thanks Chip. So are you saying that my SQL is not being executed? What would be the proper format to have it execute and populate my variable with the value of the query? I appreciate you taking the time to help me with this Chip.I thought I was structuring this correctly but apparently I''m not.


Normally I use a DLookup to grab a value and store it in a control or a string. I''m not sure if you would be able to nest all that in the where condition of the DLookup or whether you would have to use multiple ones, or just base it on a query, depending on how many times you have to run this.


这篇关于将select语句中的值赋给变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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