473,486 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

inserting autonumbers in SQL.

I have a two value table where the first field is an autonumber. I
wrote an SQL statement in visual basic for applications to insert but
it fails.

This is the code:

DoCmd.RunSQL "INSERT INTO Table1 VALUES(,cat);", True

The first one I didn't include a value because it is an autonumber and
I expected JET to automatically put in the next value. How can I get
it to work?

thanks.

Nov 13 '05 #1
1 1205
Karen Hill wrote:
I have a two value table where the first field is an autonumber. I
wrote an SQL statement in visual basic for applications to insert but
it fails.

This is the code:

DoCmd.RunSQL "INSERT INTO Table1 VALUES(,cat);", True

The first one I didn't include a value because it is an autonumber and
I expected JET to automatically put in the next value. How can I get
it to work?

thanks.

Dim strSQL As String
strSQL = "Insert Into Table1 (FieldName) Values ('cat');"
DoCmd.RunSQL strSQL

You don't need to concern yourself with adding an autonumber. That is
done automatically when you insert the record.
Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1582
by: Jim Andersen | last post by:
Hi there, After compacting/repairing a db, I was getting duplicate autonumbers. According to MS KB article http://support.microsoft.com/default.aspx?kbid=257408 This should be fixed with a...
2
2267
by: Megan | last post by:
Hi everybody- I have 2 tables, Hearings and Rulings. Both have primary keys called, CaseID, that are autonumbers. I don't want both tables to have the same autonumber. For example, if Hearings...
0
1158
by: Zen | last post by:
Can I use "autonumbers" with this configuration? Access XP + Jet 4.0 SP8 1) In some circumstances Autonumber fields cannot correctly reseeded? 2) Or they are properly stable (like Jet 3.5...
1
1660
by: Gt394 | last post by:
I have an autonumber field that provides sequential Quote numbers for each entry in a form. If an entry begins but then the user wants to cancel the entry, the Cancel button simply clears all...
3
1983
by: jeffhg582003 | last post by:
Hi, I am developing a python script which add records to a microsoft access tables. All my tables have autogenerated number fields. I am trying to capture the number generated from the insert...
3
1716
by: Zoolander | last post by:
Hello, Is it possible to insert a row between 2 existing rows that already have autonumbers? If not is it possible to disengage autonumbers so I can insert rows inbetween existing rows? I am a...
2
1396
by: MS Access confuses me 2 | last post by:
Hi Gurus, Please accept my niave understanding of Access, as i am haplessly lost and don't understand as to why the automation of autonumbers is trying to create new numbers even though i have...
1
1687
by: Julie Smith | last post by:
Hi, I have a question about autonumbers in Access db. How are they assigned when adding a new row to a table? I have table that has an autonumber column (replication ID/System.Guid) and a name...
6
1675
by: Salad | last post by:
I'm going to implement an archival database for my app. I have Table1 and Table2. Table2 is a duplicate structure of Table1. I appended records with "ID between 1 and 100", then "ID between 300...
2
3055
by: AlexanderDeLarge | last post by:
Hi! I got a problem that's driving me crazy and I'm desperately in need of help. I'll explain my scenario: I'm doing a database driven site for a band, I got these tables for their discography...
0
7105
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,...
0
6967
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...
0
7180
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...
1
6846
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...
0
7341
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...
1
4870
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...
0
4564
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
600
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.