Solved

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

Posted on 2012-03-20
8
349 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

738 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