473,651 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can not pass variable value to insert into statement

14 New Member
Hi new to the forum and visual basic.

I am attempting to fix a migration of excel to access. The excel sheets where simple copied as is into access. for example one table lists the academic history from elementary to phd and on to post doctoral work alll on the same row. I want to break that up to have each level of education as a seperate record and then relate that back to the person.

i can pull the data into a recordset
I can iterate through it by row and column and place the data into an array

from there I was going to simple insert the data into a table with new metadata.

One row for each level of education, but I can not pass the array value back to the database. It recognized the variable names literally or as functions i.e. as "edu(0) = function not array variable or undefined as the variable is not surrounded with quotes.

I thougth is should just declair a command object e.g. objcmd as new command,
define the command txt e.g. objcmd.commandt ext = "insert into table (field, field) values (edu(0),edu(1)) ",
and then execute the command e.g. objcmd.execute

but the value is either not defined or is considered a function. It works if I put in literal values like "test" or 1234 ,but not with variables. How do I pass back to the DB. the values I got from it via recordset?

any help is greatly appreciated.
Jul 26 '07 #1
5 5741
Killer42
8,435 Recognized Expert Expert
Hi. Welcome to the forum.

What you need to do is insert the values of the variables into the SQL statement, not their names. With single quotes around them if they are strings, of course.

For example...
Expand|Select|Wrap|Line Numbers
  1. objcmd.commandtext = "insert into table (field, field) values " _
  2.   & "('" & edu(0) & "', '" & edu(1) & "')"
Jul 26 '07 #2
techbuddha
14 New Member
Hi. Welcome to the forum.

What you need to do is insert the values of the variables into the SQL statement, not their names. With single quotes around them if they are strings, of course.

For example...
Expand|Select|Wrap|Line Numbers
  1. objcmd.commandtext = "insert into table (field, field) values " _
  2.   & "('" & edu(0) & "', '" & edu(1) & "')"

Hi thanks for the quick reply :-) One question would the Docmd.runSql give me the same results? given that I make the same changes to the sql statement you mentioned above?

thanks a bunch
Jul 26 '07 #3
techbuddha
14 New Member
Hi thanks for the quick reply :-) One question would the Docmd.runSql give me the same results? given that I make the same changes to the sql statement you mentioned above?

thanks a bunch

sorry nevermind I guess I should just try it. Thanks again for the help
Jul 26 '07 #4
Killer42
8,435 Recognized Expert Expert
sorry nevermind I guess I should just try it. Thanks again for the help
How did it turn out?
Jul 27 '07 #5
techbuddha
14 New Member
works great! thanks alot
Jul 31 '07 #6

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

Similar topics

5
3132
by: Seeker | last post by:
Newbie question here... I have a form with some radio buttons. To verify that at least one of the buttons was chosen I use the following code ("f" is my form object) : var btnChosen; for (count = 0; count <= 1; count++) { if (eval(f.RadioButtons.checked)) { btnChosen = true; }
110
9899
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object must be an object instead of
8
2136
by: eleftheriak | last post by:
Hi All, I have the following code. i m wondering how you pass the actual value of a variable to an insert query I want to input the value os jobnumber and finalstring strSqlEmail1 = "INSERT INTO Table1 (job, iduser) VALUES (jobnumber,
5
2266
by: strawberry | last post by:
In the function below, I'd like to extend the scope of the $table variable such that, once assigned it would become available to other parts of the function. I thought 'global $table;' would solve this but it's clear that I'm misunderstanding $variable persistence. I posted a similar enquiry over at alt.php.mysql, but I guess this is a more appropriate forum because the problems I'm having relate to PHP. Any help appreciated. ...
10
1556
by: tshad | last post by:
I want to access multiple arguments based on name passed. For example I have the following asp:textboxes: BillingAddress1 BillingAddress2 BillingCity ShippingAddress1 ShippingAddress2 ShippingCity
10
13644
by: Robert Dailey | last post by:
Hi, I noticed in Python all function parameters seem to be passed by reference. This means that when I modify the value of a variable of a function, the value of the variable externally from the function is also modified. Sometimes I wish to work with "copies", in that when I pass in an integer variable into a function, I want the function to be modifying a COPY, not the reference. Is this possible?
4
4333
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on "selectedValues" from next page for php variable this is my javascript code saved on "sendValue.js" file, <script> function updateRecordEntry(requestValue){
6
2707
by: lisp9000 | last post by:
I've read that C allows two ways to pass information between functions: o Pass by Value o Pass by Reference I was talking to some C programmers and they told me there is no such thing as pass by reference in C since you are just passing an address (or a pointer value address I guess?). So I was wondering is this correct?
12
11073
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
0
8349
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
8695
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
8576
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
7296
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
6157
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...
0
5609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4281
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2696
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
1585
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.