I tried and search around the web, but could not find an answer to it,
You see I am trying to insert 3 variables into the table, but seem like those " and ' cause the problem, No matter how I play with the ' and ", it still don;t work What wrong with the statement, could you please help.
Dim cust As String
Dim tel As String
Dim cont As String
cust = "Albert Longman"
tel = "1234567890 "
cont = "123456789"
Dim sqls As String
sqls = "insert into tblinvoice(cust omer, contact, telephone) values(' " & cust & " '," & cont & " ','" & tel & ")"
DoCmd.RunSQL strstmt
3 52178 MSeda 159
Recognized Expert New Member
try this
Dim cust As String
Dim tel As String
Dim cont As String
Dim sqls As String
cust = "Albert Longman"
tel = "1234567890 "
cont = "123456789"
sqls = "insert into tblinvoice(cust omer, contact, telephone) values('" & cust & "', '" & cont & "', '" & tel & "');"
DoCmd.RunSQL sqls
try this
Dim cust As String
Dim tel As String
Dim cont As String
Dim sqls As String
cust = "Albert Longman"
tel = "1234567890 "
cont = "123456789"
sqls = "insert into tblinvoice(cust omer, contact, telephone) values('" & cust & "', '" & cont & "', '" & tel & "');"
DoCmd.RunSQL sqls
Yeah It working, Thanks so much.
MMcCarthy 14,534
Recognized Expert Moderator MVP
You are missing a couple of single quotes, also what the spaces and you were running strstmt.
Try this -
Dim cust As String
-
Dim tel As String
-
Dim cont As String
-
Dim sqls As String
-
-
cust = "Albert Longman"
-
tel = "1234567890"
-
cont = "123456789"
-
-
sqls = "INSERT INTO tblinvoice (customer, contact, telephone) " _
-
"VALUES ('" & cust & "','" & cont & "','" & tel & "');"
-
DoCmd.RunSQL sqls
-
-
Mary
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: newbie_mw |
last post by:
Hi, I need urgent help with a novice problem. I would appreciate any
advice, suggestions... Thanks a lot in advance! Here it is:
I created a sign-up sheet (reg.html) where people fill in their first
name, last name, email, etc. The data are then sent to a PHP script
(reg.php). The data are then inserted into a table (reg) in MS SQL
server. I have declared the variables like this:
if (!(isset($_POST))) {
$FirstName = "" ;
|
by: Jack |
last post by:
I have a text file of data in a file (add2db.txt) where the entries are
already entered on separate lines in the following form:
INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great atmosphere.
Good food.", " (Harry Houdini - 03/01/2004)");
INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada",
" (Herbert Hoover - 03/03/2004)");
INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
|
by: PT |
last post by:
I got a problem. And thats.....
First of all, I got these three tables.
------------------- ------------------ ----------------------
tblPerson tblPersonSoftware tblSoftware
------------------- ------------------ ----------------------
PID PName PID* SID* SID SWName
--- ----- --- --- --- ------
1 Thomas 1 1 ...
|
by: sm |
last post by:
Hi All,
Can anybody give me the syntax to insert a record into SQL server through VB
code using variables?
The following statement is failing!
sInsertQuery = "INSERT INTO TestTab (Col1, Col2, Col3, Col4) Values(" & _
str1 & "," & dt1 & "," & str2 & "," & str3 & ")"
where str1 = "col1"
|
by: rudy |
last post by:
I'm trying to insert text values into a table in a MSAccess DB
the values are stored in string variables
Imports System.Data.OleDb ....
Dim name As String
Dim position As String
Dim site As String
Dim MDBConn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
Data Source = C:\Test.mdb")
| |
by: ak1dnar |
last post by:
There is a Error getting while i am entering records using this jsp file.
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="../Connections/conn.jsp" %>
<%
// *** Edit Operations: declare variables
// set the form action variable
String MM_editAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
|
by: bugboy |
last post by:
I'm inserting a new word into table 'w' and a definition into table 'c' which are linked in table 's' which is the relation table for the many to many relationship between 'w' and 'c'.
I've been passed 2 variables from a form; $word and $def and i'm inserting them ok but i'm having trouble getting and passing on their ID's in order to insert them into the relation table 's'
I've checked every query and they all work individually, so i...
|
by: adamace5o |
last post by:
When i try to use post variables with php and mysql i can't get the insert into statement to accept varibles as values. If i use 'test' instead of $test it does work. I suspect it is something to do with the javascript im using but i can print the correct values so why am i unable to use them to enter data to a database? sorry i am new to all this
here is the updatedata.php file
<?php
session_start();
$host="localhost"; // Host...
|
by: franc sutherland |
last post by:
Hello,
I am using Access 2003.
Is it possible to use string variables in the INSERT INTO statement?
I am using the INSERT INTO statement to add a long list of contacts to
a group by looping through the recordset (based on a linked
spreadsheet, 'tbl_group_import') and using the INSERT INTO statement
on each loop. I am using the rst.Fields.Item("FieldName") method to
|
by: bilibytes |
last post by:
Hi,
i am trying to INSERT into a table lets say 4 values:
- value1
- value2
- value3
- value4
all these values are stored in variables($var1, $var2, $var3..), except one of them which is part of the final value ($var4).
|
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,...
| |
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,...
|
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |