Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ReplicationID 1

Status
Not open for further replies.

Ray1127

Programmer
Feb 22, 2002
231
US
How do I Dim the ReplicationID from a linked SQL Server Table in MS Access VBA?
 
I suppose the same value type in Access would be an AutoNumber field type... Then set that as the Primary Key - if it is indeed supposed to be the primary key. You can only have one AutoNumber field per table.

That's for a table...

Not sure about a ReplicationID. I'd imagine if you're just looking or referencing that value in VBA, you'd just need to Dim it as a Long...

So:

Dim lngReplicationID As Long

Make sense?
 
Or wait... does the ReplicationID in SQL (I forget) create something similar or same as NewID()? If so, then you'd have to go with String, I suppose, as the variable type..
 
kjv1611 Sql Server has a datatype called Unique Identifier. When linking from Access to SQL Server that field is defined as Numeric with Replication ID in the Fieldsize. Not sure what Newid() does. Have to look that up. but did get it to work by making it a string. Thanks for that.
 
Oh, NewID is great.

NewID() is useful for at least 2 things. You can use it to add a unique ID on the fly.. You can also use it (and this is mainly what I use it for) to select random records.

For random, you could say:

SELECT TOP 1000 t.ID ,t.Name
FROM MyTable t
ORDER BY NewID()

Or for setting up a new ID field, you could select it into a new table, or update the existing one, setting your ID field equal to NewID().
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top