There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
access programming


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
allgood4's Avatar
Junior Member with 12 posts.
 
Join Date: Nov 2002
12-Dec-2002, 03:24 PM #1
Unhappy access programming
Hey guys i am trying to write a program in access and its supposed to write or addNewdata into a database:

Private Sub Add_New_Record_Click()
Dim con As ADODB.Connection
Dim cmd As ADODB.Command
Dim rst As New ADODB.Recordset

'Dim pstrSQL As String
Dim pstritem As String
Dim pstrcolumn As String
Dim pintrow As Integer
Dim pintquantity As Integer
'Dim ivlocation As AccessObject

Set rst = New ADODB.Recordset
Set con = CurrentProject.Connection
Set cmd = New ADODB.Command
Set cmd.ActiveConnection = con

pstritem = cmbItem
pstrcolumn = txtColumn
pintrow = txtrow
pintquantity = txtquantity

cmd.CommandText = "INSERT INTO icqty " & "(item, Column, Row, Quantity) Values ('" & pstritem & "','" & pstrcolumn & "'," & pintrow & "," & pintquantity & ");"



cmd.Execute
Set cmd = Nothing

Now its telling me there is a syntax error, could someone check my syntax please
Guy's Avatar
Guy Guy is offline
Senior Member with 260 posts.
 
Join Date: Feb 1999
Location: abby, BC, canada
13-Dec-2002, 03:51 PM #2
Which line is the syntax error at?

The only thing that I can see that may be causing a problem is the semicolon at the end of your SQL.
Rockn's Avatar
Computer Specs
Distinguished Member with 17,888 posts.
 
Join Date: Jul 2001
Location: Mexico of the North, MN
Experience: Disenfranchised American Male
14-Dec-2002, 03:26 PM #3
Take out all of the extra junk from the INSERT statement. Are these values coming from a form or is it a straight insert query running from a macro? If it's coming from a form you need something like this:

INSERT INTO EmployeesHistory (FirstName, LastName, Title)
VALUES (Forms!Employees!FirstName, Forms!Employees!Lastname,Forms!Employees!Title);
__________________
**Disclaimer** Anything below this line ^ is part of my signature for those that may be confused

Sadly, there are no integers on this scale, so your gangly adolescent attempt to be clever has proved futile....Dieter

I have the right "NOT" to be tolerant of others because they are different, weird, or tick me off.....Parody of Andy Rooney

There are no stupid questions, but there are a LOT of inquisitive idiots.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:40 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.