473,698 Members | 2,491 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 1356
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
1380
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
1558
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
2383
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
4382
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
1990
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
1719
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
1945
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
2664
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
1763
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
8608
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,...
0
9161
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8867
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
7732
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...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3050
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
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
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.