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

Inserting records from different source to a single table.

23
hellow Experts,
I have created a table:Temptbl
with this code,
Expand|Select|Wrap|Line Numbers
  1. strCreatetbl = "CREATE TABLE TempTbl " & _
  2.                "(Login TEXT(64), " & _
  3.                "Email TEXT(64), " & _
  4.                "Department TEXT(64), " & _
  5.                "[First name] TEXT(64), " & _
  6.                "[Last name] TEXT(64), " & _
  7.                "Net_Login Text(64) ) "
Now,the first 5 fields are same(by name,value) as my existing table"All_Table".
6th field"Net_Login" is in string:"strvalue".
I need to insert all records from my existing table"all_Table" and also from "strvalue" to the field"Net_Login".
Please suggest me with some sample code.
Thank you
Apr 11 '12 #1
4 1342
NeoPa
32,556 Expert Mod 16PB
I suggest you create an Append query (Use the QBE design grid if that's easier for you.) that selects the first 5 fields from [All_Table]. When you have the SQL from that you can use code similar to the following to insert the static value from strValue :
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3. strSQL = "INSERT INTO [TempTbl] (" & _
  4.          "       [Login]," & _
  5.          "       [email]," & _
  6.          "       [Department]," & _
  7.          "       [First Name]," & _
  8.          "       [Last Name]," & _
  9.          "       [Net_Login]) " & _
  10.          "SELECT [Login]," & _
  11.          "       [email]," & _
  12.          "       [Department]," & _
  13.          "       [First Name]," & _
  14.          "       [Last Name]," & _
  15.          "       '%N' AS [Net_Login] "
  16.          "FROM   [All_Table]"
  17. strSQL = Replace(strSQL, "%N", strValue)
Apr 11 '12 #2
usha2
23
Thank you sir,
I will definitely use this code.

I am using ADO so can i use this same in my project?

But i am not anything about "QBE design grid".
As per your guideance i will definitely try.
Apr 12 '12 #3
usha2
23
Yes sir Neopa, it works with ADo.
It append all my records from All_Table to TempTbl,
But in the field "Net_Login" ,only the last value of strValue displays repetedly.
Number of records in strValue are same as num of All_Table.
Please rectify.
should i loop some where?
Apr 12 '12 #4
NeoPa
32,556 Expert Mod 16PB
QBE = Query By Example. This is simply Design View of a query.

My suggestion doesn't match your requirement, but it does match your question. I cannot give a different solution until you change or clarify the question. Your question indicates you want the same value in every record. If this is not true, then only you know what the question should have been. I can only answer the question you post, regardless of whatever it is you're thinking.
Apr 15 '12 #5

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

Similar topics

3
by: Ben Willcox | last post by:
Hi I am having difficulty writing an SQL query to do what I want: I have 1 table with 2 columns, 'id' and 'name': tbl_names: id name -- ---- 1 Bob 2 Jeff 3 Fred
5
by: geskerrett | last post by:
I have a program that reads records from a binary file and loads them into an MS-SQL Server database. It is using a stored proc, passing the parameters. I am using pywin32 to create a...
15
by: Jaraba | last post by:
I am working in a project that I need to parse an arrayt an select records based upon the values parsed. I used the functions developed by Knut Stolze in his article 'Parsing Strings'. I am...
2
by: csgraham74 | last post by:
Hello, im using MS Access as a front end to link to MYSQL. although this is possibly an Access issue i thought someone would be able to help me. the error message "ODBC--insert on a linked table...
1
by: gouse | last post by:
Hello Friends, In a Table I am inserting more than 50,000 Records one by one. It was taking a lot of time . Is it There any good approach/solution for inserting records more than 50,000 one by one...
1
by: kitskaps | last post by:
Hey, I am working on a project in VB.NET.right now i am stuckupw ith a problem, i have different pages with different forms on it , but all the entries are supposed to be entered into a single...
4
by: Shalini Bhalla | last post by:
I have two tables emp_master and relations_details having Ins_no as a common field ................... emp_master contain all info related to employee and relation_details contain...
5
by: dos360 | last post by:
Hello, I have two tables, one is a list of activities, the other a list of participants. I want to insert one record in the activities table and then using its identity column as foreign key, I...
6
by: ashes | last post by:
Hi, I am creating an ecommerce website using Microsoft Visual Studio, VB.Net and MS Access 2003. I am new to VB.Net When someone wants to register on the website, they fill out a form and the...
5
by: rando1000 | last post by:
Okay, here's my situation. I need to loop through a file, inserting records based on a number field (in order) and if the character in a certain field = "##", I need to insert a blank record. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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.