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

I need some help with a query

65
Hi, I've build this query in VBA so it was easy to use lots af variables. But for some reason I can't get it to work properly. I'm searching on this for the last 2 hours and i'm getting desperate.

Expand|Select|Wrap|Line Numbers
  1.  db.Execute ("INSERT INTO tmpOverzicht(eadnr, naam, voornaam, geslacht, leeftijd, gewicht, lengte, BMI, fvc, fev) VALUES (" & rst.Fields(0).Value & "," & cstr(rst.Fields(1).Value) & "," & cstr(rst.Fields(2).Value) & "," & cstr(rst.Fields(4).Value) & "," & cstr(DateDiff("yyyy", rst.Fields(3).Value, now())) & "," & cstr(rst2.Fields(1).Value) & "," & cstr(rst3.Fields(1).Value) & "," & cstr((rst2.Fields(1).Value / (rst3.Fields(1).Value * rst3.Fields(1).Value))) & "," & cstr(rst4.Fields(0).Value) & "," & cstr(rst4.Fields(1).Value)) & ";")
Greetz
Twanne
Sep 20 '07 #1
1 1086
MMcCarthy
14,534 Expert Mod 8TB
When passing strings you will need to surround them with single quotes. You will also have to leave spaces after the commas and after the tablename and before the bracket. You also have to enclose the closing brackets on the VALUES in quotes. Try this out...

Expand|Select|Wrap|Line Numbers
  1.  
  2. db.Execute ("INSERT INTO tmpOverzicht (eadnr, naam, voornaam, geslacht, leeftijd, gewicht, lengte, BMI, fvc, fev) VALUES (" & _
  3. rst.Fields(0).Value & ", '" & CStr(rst.Fields(1).Value) & "', '" & CStr(rst.Fields(2).Value) & "', '" & CStr(rst.Fields(4).Value) & _
  4. "', " & CStr(DateDiff("yyyy", rst.Fields(3).Value, now())) & "', '" & CStr(rst2.Fields(1).Value) & "', '" & CStr(rst3.Fields(1).Value) & "', '" & _
  5. CStr((rst2.Fields(1).Value / (rst3.Fields(1).Value * rst3.Fields(1).Value))) & "', '" & CStr(rst4.Fields(0).Value) & "', '" & CStr(rst4.Fields(1).Value) & "');")
  6.  
Oct 3 '07 #2

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

Similar topics

9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
4
by: sah | last post by:
I need some help with the following query: DECLARE @SRV VARCHAR(20), @date smalldatetime SET @SRV = (select @@servername) SET @date = '20040901' select Srv_Name = @SRV, DB_Name = 'DB_NAME',...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
1
by: Nick | last post by:
Deear All, I would be thankful if you could help me with the following query. I have two tables TableA and TableB TableA Name: David Address: 123 West Side City: New York
7
by: K. Crothers | last post by:
I administer a mechanical engineering database. I need to build a query which uses the results from a subquery as its input or criterion. I am attempting to find all of the component parts of...
0
by: ward | last post by:
Greetings. Ok, I admit it, I bit off a bit more than I can chew. I need to complete this "Generate Report" page for my employer and I'm a little over my head. I could use some additional...
10
by: L. R. Du Broff | last post by:
I own a small business. Need to track a few hundred pieces of rental equipment that can be in any of a few dozen locations. I'm an old-time C language programmer (UNIX environment). If the only...
8
by: pamelafluente | last post by:
I am beginning aspNet, I know well win apps. Need a simple and schematic code example to start work. This is what I need to accomplish: ---------------------- Given button and a TextBox on a...
1
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: id ------------ name
3
by: pbd22 | last post by:
Hi. I need some help with structuring my query strings. I have a form with a search bar and some links. Each link is a search type (such as "community"). The HREF for the link's anchor looks...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.