Solved

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

Posted on 2012-03-20
8
337 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
 

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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

920 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now