473,387 Members | 1,585 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,387 software developers and data experts.

How Do I creat a query in VB on the fly

147 100+
I want to create a sql qry in vb that will give me info that I can use further down in the code.

I want to access the fields Rank and HireDate in my query qryEmployees for the EmployeeID used in my form that I am running the code from (these fields are not used in the form but EmployeeID from the same query is). I then want to use the values obtained freom these fields in an If statement in my code.

Thanks
Dan
Jan 19 '09 #1
4 1224
DonRayner
489 Expert 256MB
Warning this is air code
Replace YourTableName, YourForm and YourControl with your own names.

Expand|Select|Wrap|Line Numbers
  1. dim db as dao.database, rs as dao.recordset
  2. set db = currentdb()
  3. set rs = db.openrecordset("YourTableName")
  4. rs.movefirst
  5. do while not rs.eof
  6. if rs!EmployeeID = forms!YourForm!YourControl then
  7.  
  8. add your code here
  9.  
  10. rs.movelast
  11. else
  12. rs.movenext
  13. end if
  14. loop
  15.  
  16. rs.close
  17. set rs = nothing
  18. set db = nothing
  19.  
  20. rest of your code here
  21.  
  22.  
Jan 19 '09 #2
DAHMB
147 100+
Thank You! that was it!!!!
Jan 20 '09 #3
DonRayner
489 Expert 256MB
You're quite welcome, glad I could help.
Jan 20 '09 #4
NeoPa
32,556 Expert Mod 16PB
I suspect you are better off simply using the DLookup() function.
Jan 20 '09 #5

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

Similar topics

0
by: bohemia | last post by:
Hi all, I using visual c++ to creat a dll to wrapper a class that provided by another library.So I add the .lib to my win32 dll project under the link .and in my project I add some header files...
1
by: Timo | last post by:
Hi there, This is my first time here,.....I am a Perl developer by trade but currently working on Access database. Anyway,...I use this artical from Microsoft knowldge base number (285820) to...
3
by: ironpythonster | last post by:
Hi everyone,there is a simply question puzzle me: Under the CPP,where can use the char* to creat a string class for use,but under the .NET Framework? How to use C# to creat a string class as the...
0
by: dhanuka | last post by:
please i need u are help ! i would like to creat programe can not be affect in end task as we creat program in vb in that program can be remove through end task program so i need the program to...
0
by: dhanuka | last post by:
plese!dhanuka@gmail.com i need your help i hop to creat artificial intaligon program dut i have not good in vb i want to creat programe but it is hase to be easy and can be undestand well need...
1
by: dhanuka | last post by:
hai i hop to creat a program in vb, it must be a registration form through the program we have to add some details for this program Ex - we have to add some persons details i can creat that...
3
akashazad
by: akashazad | last post by:
Hi guys in my application (VB6.0). I want to creat a folder in to which i want to creat a text file . so is there any one who can give me code for that . ...
2
by: sillyr | last post by:
Hi - My database is using Access 2007. I created a simple query from two linked tables that sums up the data for all records for 11 different fields. Then I made a form that shows the totals for...
0
by: Jason7899 | last post by:
hi, i use the crystal report for creat reports and print all that i want in vb or vb.net now i looking for a such like crystal report for use in php or html all data is retrieve from a mysql...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...

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.