I am developing an application in MS Access2000 - back-end database MS SQL 2000.
When the application starts up, it refreshes link to backend like: -
ConnectStr = "ODBC;dsn=rd_venteliste;UID=xxx;PWD=yyy;DATABASE=Venteliste"
-
For Each t In CurrentDb.TableDefs
-
If t.SourceTableName <> "" Then
-
t.Connect = ConnectStr
-
t.RefreshLink
-
End If
-
Next
-
Filling a form works ok like: -
dim rs as dao.recordset
-
strSql = "SELECT * FROM Elev WHERE ElevID = " & OpenArgs
-
Set rs = CurrentDb.OpenRecordset(strSql, dbOpenSnapshot, dbSeeChanges)
-
Me.ElevID = rs.Fields!ElevID
-
Me.FamilyID = rs.Fields!FamilyID
-
.....
-
Me.AfgivendeSkole = rs.Fields!AfgivendeSkole
-
Me.Bemarkning = rs.Fields!Bemarkning
-
rs.Close
-
So do an insert: -
CurrentDb.Execute ("INSERT INTO Family " & _
-
" (Far, Mor) " & _
-
" VALUES('" & Me.Far & _
-
"', '" & Me.Mor & "')")
-
But when it comes to an update things go wrong: -
currentdb.update ("UPDATE Elev" & _
-
" SET FamilyID = '" & Me.FamilyID & _
-
"', ElevFornavn = '" & Me.ElevFornavn & _
-
"', ElevEfternavn = '" & Me.ElevEfternavn & _
-
...
-
"', Bemarkning = '" & Me.Bemarkning & _
-
"', Status = '" & Me.Status & _
-
"' WHERE ElevID = '" & Me.ElevID & "'")
-
I get error (my best translation from Danish):
"You must use option dbSeeChanges with OpenRecordSet at access to a SQL-Server-table, which has an Identity-Column"
When I try something like this: -
currentdb.update ("UPDATE Elev" & _
-
" SET FamilyID = '" & Me.FamilyID & _
-
"', ElevFornavn = '" & Me.ElevFornavn & _
-
"', ElevEfternavn = '" & Me.ElevEfternavn & _
-
...
-
"', Bemarkning = '" & Me.Bemarkning & _
-
"', Status = '" & Me.Status & _
-
"' WHERE ElevID = '" & Me.ElevID & "'", dbSeeChanges)
-
I get an error "Expected: =" ?
Can anyone explain - please ?
ravno
15 4509
Hi. Although it is an Update you want to run, the syntax CurrentDB.Updat e is not correct. Your Update should still be run using CurrentDB.Execu te ([update statement]) just as you did for the INSERT statement.
Execute is used for all types of action queries (insert, delete, update).
What is puzzling is that there is no Update method of the Database object (CurrentDB returns a pointer to the current database object that is in use). I can't explain why you are getting the error messages you quote, as I would have expected a syntax error of some kind, but I am certain that you should be using the Execute method and not the word Update in the statement you quote.
-Stewart
Hi. Although it is an Update you want to run, the syntax CurrentDB.Updat e is not correct. Your Update should still be run using CurrentDB.Execu te ([update statement]) just as you did for the INSERT statement.
Execute is used for all types of action queries (insert, delete, update).
What is puzzling is that there is no Update method of the Database object (CurrentDB returns a pointer to the current database object that is in use). I can't explain why you are getting the error messages you quote, as I would have expected a syntax error of some kind, but I am certain that you should be using the Execute method and not the word Update in the statement you quote.
-Stewart
Thank you - I am sorry to see, I've 'quoted' my code wrong - I use the currentdb.execu te("Update").
ravno
Hi again. Why not try the DoCmd.RunSQL statement instead? It would be used like this:
DoCmd.RunSQL "Update ... "
With regard to your Execute statement DbSeeChanges is a constant, and the error message makes no sense. Using the DbSeeChanges option is intended to generate a run-time error if another user is changing the data at the same time as the action query is executed - not recommended really.
I have attached the following extract from the Access help on the Execute command which I do think is more pertinent, and I would suggest enclosing the execute (without DBSeeChanges) in the transaction statements as mentioned:
For best performance in a Microsoft Jet workspace, especially in a multiuser environment, nest the Execute method inside a transaction. Use the BeginTrans method on the current Workspace object, then use the Execute method, and complete the transaction by using the CommitTrans method on the Workspace. This saves changes on disk and frees any locks placed while the query is running.
-Stewart
Hi again. Why not try the DoCmd.RunSQL statement instead? It would be used like this:
DoCmd.RunSQL "Update ... "
With regard to your Execute statement DbSeeChanges is a constant, and the error message makes no sense. Using the DbSeeChanges option is intended to generate a run-time error if another user is changing the data at the same time as the action query is executed - not recommended really.
I have attached the following extract from the Access help on the Execute command which I do think is more pertinent, and I would suggest enclosing the execute (without DBSeeChanges) in the transaction statements as mentioned:
-Stewart
Hi Stewart
Looks like the docmd.runsql () works all right - I use it together with the begintrans and the committrans
Would it be an idea to run my inserts/deletes in the same way ?
And finally - how do I avoid to have to confirm all updates - ms acces asks something like: "you're about to update 1 row - you won't be able to undo - do you wan't to update? "
ravno
Hi Ravno. Glad this worked out for you. You may not need the begin trans and committrans methods, but if these are working for you leave them in place. Your deletes and inserts will work fine with RunSQL, but as they are working with Execute I would leave them in place as is.
There is more than one way to turn off the warnings. One I use is to set the warnings off for the update and set them back on afterwards.
It is used like this: - DoCmd.SetWarnings False
-
Begin trans
-
...
-
CommitTrans
-
DoCmd.SetWarnings True
-Stewart
Hi Stewart
Looks like the docmd.runsql () works all right - I use it together with the begintrans and the committrans
Would it be an idea to run my inserts/deletes in the same way ?
And finally - how do I avoid to have to confirm all updates - ms acces asks something like: "you're about to update 1 row - you won't be able to undo - do you wan't to update? "
ravno
Hi Ravno. Glad this worked out for you. You may not need the begin trans and committrans methods, but if these are working for you leave them in place. Your deletes and inserts will work fine with RunSQL, but as they are working with Execute I would leave them in place as is.
There is more than one way to turn off the warnings. One I use is to set the warnings off for the update and set them back on afterwards.
It is used like this: - DoCmd.SetWarnings False
-
Begin trans
-
...
-
CommitTrans
-
DoCmd.SetWarnings True
-Stewart
Hi Stewart
It now looks like what I wanted - thank you very much.
One final question - I would like to be able to link to the original msAccess-database - using this -
'ConnectStr = "ODBC;DSN=RideCenter;UID=RideCenter;PWD=***;DATABASE=xxx"
-
ConnectStr = ";Database=" & FileName
-
where I use the first to connect to mssql. When I try the second and have pointed the database out in FileName - the system wants a Data Source and there it all stops
Is it maybe a new thread ?
ravno
Hi Ravno. We'd need to see the function or procedure that is doing the linking - not just the connect string.
One thing I don't yet understand from what you have mentioned is that if the Access tables you need to use are present in the database in which your code is running, they are already connected (at start-up of the database) so why do you need to connect to them again?
If you are working in code within Access you can use DAO (or ADO) recordset functionality to open the available recordsets (tables and queries) directly, unless that is you are establishing connections to another Access DB or to non-Access tables (as you did for your MYSQL tables). Perhaps a new thread is indeed needed here, but feel free to answer in this one until we see where it takes us...
-Stewart
Hi Ravno. We'd need to see the function or procedure that is doing the linking - not just the connect string.
One thing I don't yet understand from what you have mentioned is that if the Access tables you need to use are present in the database in which your code is running, they are already connected (at start-up of the database) so why do you need to connect to them again?
If you are working in code within Access you can use DAO (or ADO) recordset functionality to open the available recordsets (tables and queries) directly, unless that is you are establishing connections to another Access DB or to non-Access tables (as you did for your MYSQL tables). Perhaps a new thread is indeed needed here, but feel free to answer in this one until we see where it takes us...
-Stewart
Hi Stewart
In my front-end, the users are able to select the backend-db, using an 'OpenFileDialog ' and then the function below. It works fine, when the backend is an Access-db. I would like to set up, if it should link to an Access- or to a MS SQL-backend - the user should be able to switch - otherwise I would have to maintain 2 front-ends.
When I open the front-end, the linked-table-manager tells me, the front-end is linked to the MS-SQL-database. When I try to update all tables - 'allways prompt for new location', it asks for a datasource and I'm not able to point out my Access-db.
The following code is called, when the front-end runs: -
Public Function RefreshBackEndLinks(FileName As String) As Boolean
-
-
Dim t As DAO.TableDef
-
Dim ConnectStr As String
-
-
'ConnectStr = "ODBC;DSN=RideCenter;UID=RideCenter;" & _
-
"PWD=***;DATABASE=***"
-
ConnectStr = ";Database=" & FileName
-
-
For Each t In CurrentDb.TableDefs
-
If t.SourceTableName <> "" Then
-
t.Connect = ConnectStr
-
t.RefreshLink
-
End If
-
Next
-
RefreshBackEndLinks = True
-
End Function
-
FileName is the full path - c:\folder\....\ db.mdb' - to the Access-db. I check the t.SourceTableNa me as there are some non-linked tmp-tables in the front-end, which are not to be re-linked.
The idea is to end up with something like this: -
....
-
Select BackEndType
-
Case MSSQL
-
ConnectStr "ODBC;DSN=RideCenter;UID=RideCenter;" & _
-
"PWD=***;DATABASE=***"
-
Case ACCESS
-
ConnectStr = ";Database=" & FileName
-
End Select
-
.....' Refreshlinks
-
I have noticed, that t.SourceTableNa me='dbo.tablena me' for the MS SQL database-link, while it is t.SourceTableNa me='tablename' in Access-link.
ravno
sierra7 446
Recognized Expert Contributor
Hi , I'm just registering to see how this works out!
Ravno, is your front end in ANSI 92 mode ?
S7
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: w |
last post by:
Hello all!!!
For a year and a half now, we have been developing different Access
2000 applications. Most of them are access frontend and access
backends. Some of them have SQL server 2000 as a backend. There is one
application, which consists of a frontend and 3 backend mdb's.
Different companies (80) are using the application:
1. Companies with just one pc and one user.
2. Companies with a Cytrix environment.
|
by: matt bourke |
last post by:
Hi,
Can you please tell me what the advantage is of using an access backend with
a VB frontend OVER access as a frontend and backend.
M
|
by: Wayne Aprato |
last post by:
I have several Access 97 databases which are split into front end and
back end running off a server. The front end mde is shared by 2 or 3
- absolute maximum of 6 concurrent users. This scenario has been
working flawlessly for about 2 years. I am now at a point where these
databases need to be converted to Access 2003.
I think I read somewhere on this forum that the newer versions of
Access are not as tolerant to multiple users...
|
by: DD |
last post by:
Hi
I have a split database, that is packaged and used in a runtime
enviroment.
I want to make it easier for the user, a button on the frontend
"Export Backend"
They can click on the button then search for the backend and then save
the backend to a CD or Floppy.
|
by: Sukkel |
last post by:
When I define relations in the Backend of my Database, everything works
fine. I get these funny lines (with 1 and "OO") between the fields of
the different table that indicate a one to many relationship.
Then, when I try to build a query in the frontend, these signs
disappear in the query design window, and as a consequence, the form
wizzard based on such a query won´t let me construct a subform in the
main form.
I could make my...
| |
by: PC Datasheet |
last post by:
I have zero experience with using a SQL database for a backend and Access
for a frontend. I have some questions:
1. Does an SQL database have tables?
2. How does Access connect to the data in an SQL database? Linking,
importing, or ???
3. Earlier today there was a thread regarding DAO and ADO. In the thread it
was said that ADO is very useful when the backend is a SQL database. Could
someone explain that?
|
by: rdemyan via AccessMonster.com |
last post by:
My front-end code manually links to the backend file.
I was wondering what stops Access from linking to the system tables in the
backend file. Is it just by virtue that they are hidden?
This has recently come up because I've been playing around with converting my
front end to A2003 format. At some point, I had a corruption issue with a
system file MSStorage something. Access kept saying it couldn't find it.
When I looked in the db...
|
by: philelpko |
last post by:
Good Morning all,
Lost once again which is becoming a common occurance atm.
My database has successfully been broken into a frontend and a backend db. A problem has now arisen as it has become apparant that db managers need to add additional field names to a table.
I cant find anyway that access will allow you to create additional fields to already existing tables in the backend from the frontend.
In a nutshell, is it possible to...
|
by: Kaustubha B S |
last post by:
hi! this is Kaustubha from BLR , INDIA
i had a doubt about Client/server technology
1) how does a backend-frontend tool in clientserver technology work
and what are the differrent software tools that are used to
make this thing work
for example: RDBMS (oracle) and FORMS are used as
backend-frontend tool in clientserver technology
...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |