Wrox Programmer Forums
|
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 17th, 2003, 08:35 AM
Registered User
 
Join Date: Aug 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do do a loop with variables

I am not a programmer, and there are no resources at work to help me with this improvement.

Current code works. It is just longer than it should be.

goal: Write a loop with the source data that needs to have a variable defined is from another table. The process is automated in a VB script. Currently, it is just one huge file with multiple very common functions. It could be made much more efficient if I used a variable for the query in the FROM clause and variable for the known WHERE clause.

The variable (project name) is unique. the format for the FROM source is:

qry<Project>Data

The format using project name will define the string for the WHERE clause. The syntax is complete for normal SQL. I would assume that I would do something like:

Dim strWhere as String

strWhere = <sql where extract>


A simple explanation of dealing with variables inserted, with the loop or case would be appreciated.

Thanks!

 
Old December 15th, 2003, 07:50 AM
Authorized User
 
Join Date: Jun 2003
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

dim MyVariable

'code here to set myVariable

then

mySQL = "select * from table where colA = " & myVariable (numeric)
mySQL = "select * from table where colA = '" & myVariable & "'" (string)








Similar Threads
Thread Thread Starter Forum Replies Last Post
i++ and ++i in a "for" loop frjacquemin BOOK: Beginning Mac OS X Programming 3 May 18th, 2009 07:37 AM
Do Loop? emanuele.musa VB How-To 0 July 27th, 2007 05:50 AM
UserType Variables--loop thru their names? Paul Gerken VB How-To 10 December 4th, 2006 01:08 PM
Pass variables from array inside a loop dustygn PHP How-To 2 May 3rd, 2006 05:35 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.