Solved

Passing <uniqueidentifier> from MS Access 2007 to SQL Database Table

Posted on 2012-03-20
8
340 Views
Last Modified: 2012-03-26
I am creating a Access Form (2007) that will be utilize to update and create new records that are stored in a backend SQL Server 2008 Table.  One of my fields in this table is a UniqueID.  From SQL, I can use newid() to create this unique value.  How can do this in the actual Access Form OR what are my options for this?
0
Comment
Question by:HMSImage
  • 4
  • 3
8 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37742901
There are many ways...

One is to use a function that simply adds 1 to the highest number

Function NextNumber() as long
    NextNumber=Dmax("YourIDField","YourTable")+1
end function.

This may not be perfect for a multi-user environment...

So lets see what other experts post...

JeffCoachman
0
 

Author Comment

by:HMSImage
ID: 37753885
Thanks Jeff, but you are correct.  This is a multi-user environment and this method may cause problems.  Are there other options for doing this?
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 100 total points
ID: 37754048
If I am understanding your question...

The act of creating the record in Access should trigger the SQL to generate the next number.
Do you have an "Identity" (auto-number) field in this SQL table?
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

Author Comment

by:HMSImage
ID: 37754202
yes.

I have a UniqueID field in my SQL table.  It is type uniueidentifier and a primary key.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37754374
So are you saying if you add a record in Access, the SQL autonumber is not created?
0
 
LVL 61

Accepted Solution

by:
mbizup earned 400 total points
ID: 37756637
Iin addition to the property settings you mentioned, you should set this up as an identity column.

"Is Identity" should be set to Yes, so that your column autonumbers.  See this for details (under the identity specification heading):
http://msdn.microsoft.com/en-us/library/ms177173.aspx

If you have not already done so, your settings should look like this:
Ident.PNG
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37757496
Thanks for chiming in mbizup...
As you know SQL is not my strong point...

;-)

Jeff
0
 

Author Closing Comment

by:HMSImage
ID: 37767334
Thanks for the help on this one.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question