473,732 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Building SQL string need guidance

41 New Member
Good AM:

I have struggling with constructing a string to execute some SQL. Here is my update statement



update teacherresource s set [student_enroll] = (([student_enroll] / variable1) * Variable 2 )) where(( trschool_id = 12 and [tryear] = forms!form1!yea rcombo) or (where trschool_id = 13 and [tryear = forms!form!year combo))

the variables are both numeric. I know the variables have to be converted to strings, i.e Crst().

If anyone knows of a good tutorial on this subject I would live to see it. I am lost in a sea of quotes and data mismatches. Thanks much,

Patti
Mar 30 '08 #1
3 1359
ADezii
8,834 Recognized Expert Expert
Good AM:

I have struggling with constructing a string to execute some SQL. Here is my update statement



update teacherresource s set [student_enroll] = (([student_enroll] / variable1) * Variable 2 )) where(( trschool_id = 12 and [tryear] = forms!form1!yea rcombo) or (where trschool_id = 13 and [tryear = forms!form!year combo))

the variables are both numeric. I know the variables have to be converted to strings, i.e Crst().

If anyone knows of a good tutorial on this subject I would live to see it. I am lost in a sea of quotes and data mismatches. Thanks much,

Patti
Hello Patti, try:
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3. 'For Numeric Form values
  4. strSQL = "Update teacherresources set [student_enroll] = (([student_enroll] / variable1) * Variable 2) " & _
  5.          "Where [trschool_id] = 12 And [tryear] = " & Forms!form1!yearcombo & _
  6.          " Or ([trschool_id] = 13 And [tryear] = " & Forms!Form!yearcombo & ");"
Mar 30 '08 #2
patriciashoe
41 New Member
Thanks for the quick reply. The variables are not translating. I believe I read somewhere that you can use the cstr() function to turn them into strings which adds some complexity to the resulting string. I have been using a message box to check the string. Any suggestions on how to tweak your string? thanks again,

Patti
Mar 30 '08 #3
NeoPa
32,569 Recognized Expert Moderator MVP
Patti, If you can explain exactly what you're trying to do here I'm sure I can help you.

The main trick is to understand the difference between what is the text in your VBA - and what this resolves to before being passed across to the SQL interpreter (or engine).

Some tutorials on (related) matters are :
Basic SQL Syntax for Access Queries
ANSI Standards in String Comparisons
Literal DateTimes and Their Delimiters (#)
Quotes (') and Double-Quotes (") - Where and When to use them

Let me know if you'd like to take this further.
Apr 3 '08 #4

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

Similar topics

1
1383
by: James | last post by:
I don't know where to start and would appreciate some help please... I have a mySql database with tblDiary Date Employee Client 1/1/04 Smith Bloggs 2/1/04 Jones United 2/1/04 Smith Central .....etc
0
1560
by: Sean Williams | last post by:
I have been working in this problem for weeks and I was determined to sort it myself however I feel I need guidance to proceed forward. What I am trying to produce is some asp code that can split categories and group from a text string that is delimited by a "| ". (see string examples below). I have managed to find some javascript that will handle the different levels of categories without having to keep refreshing the page. So I want...
3
2386
by: new_GUY | last post by:
I have a HUGE project (at least for me) and need some guidance. I am trying to create a database for a local university movie club that allows users to input there basic personal information (name, address, telephone number) as well as movies in there collection. The movies will be categorized by genre (comedy, romance, horror, etc.) and title. I want to be able to let the users add and remove movies to their list of movies they own,...
2
4386
by: James Aguilar | last post by:
Hey all, I have a program that runs the Manber-Myers suffix array search algorithm with longest common prefix values. I need an efficient way to represent a sequential array of characters to be passed into the algorithm. Here are the features I need for the representation: * Must be randomly accessible in constant time * Must be capable of efficiently storing strings of more than 10 million characters
8
1993
by: Jacob Arthur | last post by:
How would I go about using a custom select string that is passed from a form to the SelectCommand parameter of SqlDataSource? I tried: SelectCommand = "<% Request.Form("hdnSelect") %>" but I got an error about putting <% %> tags in a literal. I tried taking out the quotes (the " ") and it didn't do any good. I'm trying to use the built in ASP.NET 2.0 DataList control, but I haven't come up with anything.
0
1720
by: s | last post by:
I need to develop a multiuser database application to be used by four people(The number of users are not likely to increase). It is for storing records of different versions of particular papers. I am new to building such an application. I would like to know what would the requirements be for using Access as the means for building the multiuser database. Two of the four use Access 2000(running Windows 98) and other two use Access...
2
1948
by: csman24 | last post by:
I'm just looking for some guidance so that I get a start on a school project. Need to write 3 kind of event for a Bus, Passenger, transit system in which: -person: arrives at bus Q after random time (i already have a prog. to produce those random number) what indicates the arrival of a next passenger to bus Q. -arrival: of bus at stop. if no one in Q, bus continues to next stop and event of its arrival is generated. Else,...
4
2666
by: Phil Latio | last post by:
I'm kind of looking for some guidance in respect of this obstacle I'm up against - please let me expand; I have an option group with three options (AND, OR, & NONE) and a text box which will accept free text - the text will become criteria in a SQL string and depending upon the option the WHERE clause will be AND/OR LIKE textCriteria1 AND/OR LIKE textCriteria2.... I'm trying to create a VBA function to take the free text and break up...
1
1765
by: Robert Neville | last post by:
Basically, I want to create a table in html, xml, or xslt; with any number of regular expressions; a script (Perl or Python) which reads each table row (regex and replacement); and performs the replacement on any file name, folder, or text file (e.g. css, php, html). For example, I often rename my mp3 (files); the folder holding the mp3 files; and replace these renamed values in a playlist/m3u/xml file. The table should hold clean...
0
8944
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8773
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9234
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9180
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6733
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3259
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2177
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.