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(customer, contact, telephone) values(' " & cust & " '," & cont & " ','" & tel & ")"
DoCmd.RunSQL strstmt
3 52119 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(customer, 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(customer, 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...
|
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...
|
by: PT |
last post by:
I got a problem. And thats.....
First of all, I got these three tables.
------------------- ------------------ ----------------------
tblPerson tblPersonSoftware ...
|
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,...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |