Sylvain Lafontaine
2009-06-20 17:59:38 UTC
Often, the upsizing Wizard will forget to set the primary key on the upsized
table; this might be the reason why you cannot add a new record but they are
other possibilities as well. Without you showing us the design of the
tables - both before and after the upsizing - and of the query used as the
record source of the form, it's hard to say anything more.
Usually, it's not hard to have a version that will work equally well against
either an Access/JET backend or a SQL-Server backend but you'll have to make
adjustement to your code here and there. For example, you often have to add
the dbSeeChanges option when executing code or opening a recordset and when
you need to retrieve a new identity value (the equivalent of Access'
autonumber field) for a new record on SQL-Server, its value is not known
until the record has been added to the database; so you'll have to adapt
your VBA code in order to distinguish between these two cases; for example:
' Creating a DAO recordset:
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("MyTable", dbOpenDynaset, dbAppendOnly Or
dbSeeChanges)
rs.AddNew
' Adding some data to the new record:
rs!MyNumber = 1
rs!MyName = "MyName"
' And now, retrieving the the ID value:
#If SQLServer = 1 Then
rs.Update
rs.Bookmark = rs.LastModified
NewId = rs!TableId
#Else
NewId = rs!TableId
rs.Update
#End If
In this example, "SQLServer=1" is a property that I've added in the VBA
Editor under Tools | Options | Property. Notice also the option
dbSeeChanges that I've added.
--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)
table; this might be the reason why you cannot add a new record but they are
other possibilities as well. Without you showing us the design of the
tables - both before and after the upsizing - and of the query used as the
record source of the form, it's hard to say anything more.
Usually, it's not hard to have a version that will work equally well against
either an Access/JET backend or a SQL-Server backend but you'll have to make
adjustement to your code here and there. For example, you often have to add
the dbSeeChanges option when executing code or opening a recordset and when
you need to retrieve a new identity value (the equivalent of Access'
autonumber field) for a new record on SQL-Server, its value is not known
until the record has been added to the database; so you'll have to adapt
your VBA code in order to distinguish between these two cases; for example:
' Creating a DAO recordset:
Dim rs As DAO.Recordset
Set rs = db.OpenRecordset("MyTable", dbOpenDynaset, dbAppendOnly Or
dbSeeChanges)
rs.AddNew
' Adding some data to the new record:
rs!MyNumber = 1
rs!MyName = "MyName"
' And now, retrieving the the ID value:
#If SQLServer = 1 Then
rs.Update
rs.Bookmark = rs.LastModified
NewId = rs!TableId
#Else
NewId = rs!TableId
rs.Update
#End If
In this example, "SQLServer=1" is a property that I've added in the VBA
Editor under Tools | Options | Property. Notice also the option
dbSeeChanges that I've added.
--
Sylvain Lafontaine, ing.
MVP - Windows Live Platform
Email: sylvain2009 sylvainlafontaine com (fill the blanks, no spam please)
Independent consultant and remote programming for Access and SQL-Server
(French)
I have an Access database that I have been developing for about 2 years
now.
I have about 150 tables and over 600 queries. Just the front-end of my
database is 30 Meg. One of my customers is now adding about 100 Meg of
data
per year and has asked me to give him a quote on a SQL back-end. They
already have the SQL Server. Note: My other customers are currently
low-end
users and may never outgrow Access.
So I'm looking at keeping two versions one with SQL and one with Access.
How likely is it if I just upsize the tables and leave the queries alone
that
I will be able to make my front-end work for both versions? I haven't
tried
SSMA yet but when I ran the upsizing wizard a couple of versions ago my
database appeared to work for existing records but I was unable to add new
through my forms using Access's built in add new records button. I never
took it beyond this initial test.
I'd love to be able to just upsize the tables and then still continue
development in Access Or should I just go for it and do both the queries
and
tables for the SQL version?
I'd appreciate any advice you can give me since my customers are
non-profits
and much of the work I do is pro-bono.
-Mark-
--
Mark Annett
ISPManSys.com
now.
I have about 150 tables and over 600 queries. Just the front-end of my
database is 30 Meg. One of my customers is now adding about 100 Meg of
data
per year and has asked me to give him a quote on a SQL back-end. They
already have the SQL Server. Note: My other customers are currently
low-end
users and may never outgrow Access.
So I'm looking at keeping two versions one with SQL and one with Access.
How likely is it if I just upsize the tables and leave the queries alone
that
I will be able to make my front-end work for both versions? I haven't
tried
SSMA yet but when I ran the upsizing wizard a couple of versions ago my
database appeared to work for existing records but I was unable to add new
through my forms using Access's built in add new records button. I never
took it beyond this initial test.
I'd love to be able to just upsize the tables and then still continue
development in Access Or should I just go for it and do both the queries
and
tables for the SQL version?
I'd appreciate any advice you can give me since my customers are
non-profits
and much of the work I do is pro-bono.
-Mark-
--
Mark Annett
ISPManSys.com