473,408 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

using variables in queries

110 100+
hello all

how do i use a variable in a query for the 'criteria'? i can easily do this in vba, but im trying to avoid using code right now...dont ask...i hate it too....lol

thanx
Mar 30 '07 #1
7 1519
Denburt
1,356 Expert 1GB
Not really, I need to know where this variable would get it's information from? If it is user input the in the criteria section place the following:

[GIVE ME MY CRITERIA!!!!]

Now if you want to extract it from an open form:

Forms!MyForm!MyField


Does this help?
Mar 30 '07 #2
developing
110 100+
wow tha twas fast...not really tho, im using a global variable that has infromation about a user.

i looked around thru google. turns out i kinda HAVE to use code...so got this

someone make sure pls? i need the row source to be NAME1 where ADIENST is gblUSER. The bound column is suppsed to be ID....
all in the same table. also, id like it so only NAME1 was displayed in the cbo....



Expand|Select|Wrap|Line Numbers
  1. With Me.cboCustomerName
  2. .RowSource = "SELECT NAME1, ID" _
  3.     & " FROM SYSADM_KU_KUNDEN " _
  4.     & " Where  [ADIENST] = " & gblUSER _
  5.     & " ORDER BY SYSADM_KU_KUNDEN.NAME1;"
  6. .BoundColumn = 2
  7. End With
Mar 30 '07 #3
Denburt
1,356 Expert 1GB
Looks O.K. as long as both fields below refer to a number.

& " Where [ADIENST] = " & gblUSER _


If Text then

& " Where [ADIENST] = '" & gblUSER & "'" _


Good luck let us know how it goes.
Mar 30 '07 #4
developing
110 100+
works like a charm thanks!

yeah i was missing the string syntax....thanx again
Mar 30 '07 #5
Denburt
1,356 Expert 1GB
No problem glad I could help.
Mar 30 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
No problem glad I could help.
Actually there is an easier way of doing this.

Assuming a global variable of

Expand|Select|Wrap|Line Numbers
  1. Global i As Integer
Then this function
Expand|Select|Wrap|Line Numbers
  1. Function getGbl()
  2.  
  3.     getGbl = i
  4.  
  5. End Function
  6.  
You can now simply use getGbl() as the criteria on your field.

Mary
Apr 1 '07 #7
developing
110 100+
Actually there is an easier way of doing this.

Assuming a global variable of

Expand|Select|Wrap|Line Numbers
  1. Global i As Integer
Then this function
Expand|Select|Wrap|Line Numbers
  1. Function getGbl()
  2.  
  3.     getGbl = i
  4.  
  5. End Function
  6.  
You can now simply use getGbl() as the criteria on your field.

Mary
so SQL takes in functions as parameters eh? sweet, definately gonna help me later on. Thanks
Apr 2 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: pranab_bajpai | last post by:
So I want to define a method that takes a "boolean" in a module, eg. def getDBName(l2): .... Now, in Python variables are bound to types when used, right? Eg. x = 10 # makes it an INT...
175
by: Sai Hertz And Control Systems | last post by:
Dear all, Their was a huge rore about MySQL recently for something in java functions now theirs one more http://www.mysql.com/doc/en/News-5.0.x.html Does this concern anyone. What I...
2
by: PaJeeper | last post by:
I'm trying to write code that will automatically add a specified number of records to a table using variables derived from queries. I am attempting to do this with DAO. Background. I have...
0
by: lnd | last post by:
A few question regarding PostgreSQL handling of queries: - Is each query submitted parsed and planned even if it is identical to a query submitted before? For example, 10 queries "select * from...
6
by: duke442games | last post by:
Hi Gang I am working on fixing a corrupted database (A yearly proc did not handel the conversion from year to year and now I have to fix the resulting lines in the DB). Most of my fixes I have...
15
by: Wes Groleau | last post by:
When I try to import from Access, the DTS wizard only allows me to import tables and queries. OK, I'm not surprised the "macros" and reports don't come over. But it executes each query, and...
1
by: Mike Heywood | last post by:
Hi, I am currently trying to automate a process that I have been studying the manual results from for a while. The process simply identifies events that meet certain criteria and at the moment...
19
by: Mitesh | last post by:
Hi all, I have the following code: $req = "SELECT * FROM table1"; $res = mysql_query($req); if(!$res) return;
3
accessbunnie
by: accessbunnie | last post by:
Hello Access Users! I am a bit of an Access novice and am currently creating a database and have come up against a huge (for me!) road block. I do not write in Access code and instead, tend to...
2
by: kstevens | last post by:
Ok, the first thing i found out is that i should be using 'Public' instead of 'Global", so i did that. Here is what i tried to do (yes i have read as much as i could before i posted...... i...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.