We are converting my Access97 back end to SQL Server and almost have it
all working. The current problem has to do with one situation in which
I have to programmaticall y (still in the Access97 front end) add a
record to an existing table. Here is the code:
If arg = cintBatchReg Then
Set newrec = db.OpenRecordse t("SELECT * FROM [workshop assignments]", _
dbOpenDynaset, dbSeeChanges)
Set newrec = db.OpenRecordse t("SELECT * FROM _
[workshop assignments]", dbOpenDynaset, dbSeeChanges)
newrec.AddNew ' assign the workshop
newrec![ComboWS] = WSKey
newrec![Participant] = IndividualID
newrec![Priority] = WSPriority
newrec![Assigned] = True
newrec.Update
End If
Everything goes smoothly until I hit the newrec.Update and receive a
"3146 ODBC call failed" error.
We've tried:
1. checked all the permissions. I am able to add records through bound
forms just fine.
2. Changed dbOpenDynaset to other things and got different errors.
3. Added dbOptimistic locking which had no effect.
Got any other ideas?
Thanks,
Rebecca 8 1754
Well, we went back to the table declaration in the SQL Server and
changed the bit fields to Allow Nulls. Problem fixed.
Thanks anyway,
Rebecca
Rebecca wrote: We are converting my Access97 back end to SQL Server and almost have it all working. The current problem has to do with one situation in which I have to programmaticall y (still in the Access97 front end) add a record to an existing table. Here is the code:
If arg = cintBatchReg Then Set newrec = db.OpenRecordse t("SELECT * FROM [workshop assignments]", _ dbOpenDynaset, dbSeeChanges) Set newrec = db.OpenRecordse t("SELECT * FROM _ [workshop assignments]", dbOpenDynaset, dbSeeChanges)
newrec.AddNew ' assign the workshop newrec![ComboWS] = WSKey newrec![Participant] = IndividualID newrec![Priority] = WSPriority newrec![Assigned] = True newrec.Update End If
Everything goes smoothly until I hit the newrec.Update and receive a "3146 ODBC call failed" error.
We've tried: 1. checked all the permissions. I am able to add records through bound forms just fine. 2. Changed dbOpenDynaset to other things and got different errors. 3. Added dbOptimistic locking which had no effect.
Got any other ideas?
Thanks, Rebecca
Rebecca <Re*****@JaxonF amily.net> wrote: We are converting my Access97 back end to SQL Server and almost have it all working. The current problem has to do with one situation in which I have to programmaticall y (still in the Access97 front end) add a record to an existing table. Here is the code:
If arg = cintBatchReg Then Set newrec = db.OpenRecordse t("SELECT * FROM [workshop assignments]", _ dbOpenDynaset, dbSeeChanges) Set newrec = db.OpenRecordse t("SELECT * FROM _ [workshop assignments]", dbOpenDynaset, dbSeeChanges)
newrec.AddNew ' assign the workshop newrec![ComboWS] = WSKey newrec![Participant] = IndividualID newrec![Priority] = WSPriority newrec![Assigned] = True newrec.Update End If
Glad you figured out your problem however this logic will waste resources and slow
things down. You are going to get a recordset of all the records in the table but
you are just adding a record.
You'd be much better off doing an INSERT ... VALUES query. Or opening the
recordset using dbAppendOnly.
Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at http://www.granite.ab.ca/accsmstr.htm
On Sun, 05 Sep 2004 22:46:48 GMT, Rebecca <Re*****@JaxonF amily.net>
wrote:
I wonder what would happen if you don't allow nulls, and write:
newrec![Assigned] = 1 ' bit can only be 1 or 0, not -1
If that works that would be far preferrable in most applications. It's
hard to imagine what it means for Assigned to be Null, rather than
Assigned or Not_Assigned. Perhaps it would indicate "I don't know".
Only in rare situations should you weaken the database design to
support front-end programming limitations.
-Tom. Well, we went back to the table declaration in the SQL Server and changed the bit fields to Allow Nulls. Problem fixed.
Thanks anyway, Rebecca
Rebecca wrote: We are converting my Access97 back end to SQL Server and almost have it all working. The current problem has to do with one situation in which I have to programmaticall y (still in the Access97 front end) add a record to an existing table. Here is the code:
If arg = cintBatchReg Then Set newrec = db.OpenRecordse t("SELECT * FROM [workshop assignments]", _ dbOpenDynaset, dbSeeChanges) Set newrec = db.OpenRecordse t("SELECT * FROM _ [workshop assignments]", dbOpenDynaset, dbSeeChanges)
newrec.AddNew ' assign the workshop newrec![ComboWS] = WSKey newrec![Participant] = IndividualID newrec![Priority] = WSPriority newrec![Assigned] = True newrec.Update End If
Everything goes smoothly until I hit the newrec.Update and receive a "3146 ODBC call failed" error.
We've tried: 1. checked all the permissions. I am able to add records through bound forms just fine. 2. Changed dbOpenDynaset to other things and got different errors. 3. Added dbOptimistic locking which had no effect.
Got any other ideas?
Thanks, Rebecca
Tony Toews wrote: Rebecca <Re*****@JaxonF amily.net> wrote:
We are converting my Access97 back end to SQL Server and almost have it all working. The current problem has to do with one situation in which I have to programmaticall y (still in the Access97 front end) add a record to an existing table. Here is the code:
If arg = cintBatchReg Then Set newrec = db.OpenRecordse t("SELECT * FROM [workshop assignments]", _ dbOpenDynaset, dbSeeChanges) Set newrec = db.OpenRecordse t("SELECT * FROM _ [workshop assignments]", dbOpenDynaset, dbSeeChanges)
newrec.AddNew ' assign the workshop newrec![ComboWS] = WSKey newrec![Participant] = IndividualID newrec![Priority] = WSPriority newrec![Assigned] = True newrec.Update End If
Glad you figured out your problem however this logic will waste resources and slow things down. You are going to get a recordset of all the records in the table but you are just adding a record.
You'd be much better off doing an INSERT ... VALUES query. Or opening the recordset using dbAppendOnly.
Tony --
Tony,
This sounds like a much better solution. We were worrying about the
performance aspect of doing this function across the web. Thanks for
your advice.
Rebecca
Actually there was never a real reason why it was not allowed to be
null, so it doesn't bother us to allow them now. These records are
always going to have the "assigned" bit set to true, it's the three
other boolean fields that aren't relevant in this procedure that we're
allowing to default to false by simply not setting them at all. Am I
right that that's what will happen?
Thanks,
Rebecca
Tom van Stiphout wrote: On Sun, 05 Sep 2004 22:46:48 GMT, Rebecca <Re*****@JaxonF amily.net> wrote:
I wonder what would happen if you don't allow nulls, and write: newrec![Assigned] = 1 ' bit can only be 1 or 0, not -1
If that works that would be far preferrable in most applications. It's hard to imagine what it means for Assigned to be Null, rather than Assigned or Not_Assigned. Perhaps it would indicate "I don't know".
Only in rare situations should you weaken the database design to support front-end programming limitations.
-Tom. Well, we went back to the table declaration in the SQL Server and changed the bit fields to Allow Nulls. Problem fixed.
Thanks anyway, Rebecca
Rebecca wrote:
We are converting my Access97 back end to SQL Server and almost have it all working. The current problem has to do with one situation in which I have to programmaticall y (still in the Access97 front end) add a record to an existing table. Here is the code:
If arg = cintBatchReg Then Set newrec = db.OpenRecordse t("SELECT * FROM [workshop assignments]", _ dbOpenDynaset, dbSeeChanges) Set newrec = db.OpenRecordse t("SELECT * FROM _ [workshop assignments]", dbOpenDynaset, dbSeeChanges)
newrec.AddNew ' assign the workshop newrec![ComboWS] = WSKey newrec![Participant] = IndividualID newrec![Priority] = WSPriority newrec![Assigned] = True newrec.Update End If
Everything goes smoothly until I hit the newrec.Update and receive a "3146 ODBC call failed" error.
We've tried: 1. checked all the permissions. I am able to add records through bound forms just fine. 2. Changed dbOpenDynaset to other things and got different errors. 3. Added dbOptimistic locking which had no effect.
Got any other ideas?
Thanks, Rebecca
On Mon, 06 Sep 2004 02:35:13 GMT, Rebecca <Re*****@JaxonF amily.net>
wrote:
No. And you can easily verify that. If you allow null, and don't
provide a value, the field will be null once your update is finished.
You can set a default value of 0 to indicate False, and then make the
field required by setting Allow Nulls to False. That's what I would
recommend.
-Tom. Actually there was never a real reason why it was not allowed to be null, so it doesn't bother us to allow them now. These records are always going to have the "assigned" bit set to true, it's the three other boolean fields that aren't relevant in this procedure that we're allowing to default to false by simply not setting them at all. Am I right that that's what will happen?
Thanks, Rebecca
Tom van Stiphout wrote: On Sun, 05 Sep 2004 22:46:48 GMT, Rebecca <Re*****@JaxonF amily.net> wrote:
I wonder what would happen if you don't allow nulls, and write: newrec![Assigned] = 1 ' bit can only be 1 or 0, not -1
If that works that would be far preferrable in most applications. It's hard to imagine what it means for Assigned to be Null, rather than Assigned or Not_Assigned. Perhaps it would indicate "I don't know".
Only in rare situations should you weaken the database design to support front-end programming limitations.
-Tom. Well, we went back to the table declaration in the SQL Server and changed the bit fields to Allow Nulls. Problem fixed.
Thanks anyway, Rebecca
Rebecca wrote:
We are converting my Access97 back end to SQL Server and almost have it all working. The current problem has to do with one situation in which I have to programmaticall y (still in the Access97 front end) add a record to an existing table. Here is the code:
If arg = cintBatchReg Then Set newrec = db.OpenRecordse t("SELECT * FROM [workshop assignments]", _ dbOpenDynaset, dbSeeChanges) Set newrec = db.OpenRecordse t("SELECT * FROM _ [workshop assignments]", dbOpenDynaset, dbSeeChanges)
newrec.AddNew ' assign the workshop newrec![ComboWS] = WSKey newrec![Participant] = IndividualID newrec![Priority] = WSPriority newrec![Assigned] = True newrec.Update End If
Everythin g goes smoothly until I hit the newrec.Update and receive a "3146 ODBC call failed" error.
We've tried: 1. checked all the permissions. I am able to add records through bound forms just fine. 2. Changed dbOpenDynaset to other things and got different errors. 3. Added dbOptimistic locking which had no effect.
Got any other ideas?
Thanks, Rebecca
Rebecca wrote: Well, we went back to the table declaration in the SQL Server and changed the bit fields to Allow Nulls. Problem fixed.
Bad idea when using an Access front end, you should set bit fields to
NOT NULL and default to 0. The reason being in Access, a Yes/No field
cannot be null, if you bind any forms to this table with nulls in bit
fields you will end up in all sorts of trouble.
BTW, in trapping ODBC Errors...
<---
Dim e As Error, strODBCError As String
On Error Goto ErrTrap
.... ' do stuff
ErrTrap:
Select Case Err.Number
Case 3146
For each e in DbEngine.Errors
strODBCError = strODBCError & e.Description & VbCr
Next
MsgBox strODBCError,16 ,"Oops"
Resume ...
Case ...
... Normal Error handling
End Select
--->
--
\\\\\\
\\ \\ Windows is searching
\ \ For your sig.
\ \ Please Wait.
\__\
Hmmm, I've actually made quite a few of those records since I last
wrote, and even with those nulls in the bit fields it doesn't seem to
mind. When I display that table, they display as "0", and when those
records are represented in the subform where they appear after I've
created them, it doesn't cause a problem.
I do see what you mean though, and agree that it would make the code
more correct if I were to change it the way you say.
Thanks for the advice about trapping ODBC errors. We've noticed that
the error descriptions it gives are pretty vague. Your procedure will
be very helpful.
Rebecca
Trevor Best wrote: Rebecca wrote:
Well, we went back to the table declaration in the SQL Server and changed the bit fields to Allow Nulls. Problem fixed.
Bad idea when using an Access front end, you should set bit fields to NOT NULL and default to 0. The reason being in Access, a Yes/No field cannot be null, if you bind any forms to this table with nulls in bit fields you will end up in all sorts of trouble.
BTW, in trapping ODBC Errors...
<--- Dim e As Error, strODBCError As String On Error Goto ErrTrap ... ' do stuff
ErrTrap: Select Case Err.Number Case 3146 For each e in DbEngine.Errors strODBCError = strODBCError & e.Description & VbCr Next MsgBox strODBCError,16 ,"Oops" Resume ... Case ... ... Normal Error handling End Select ---> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Dugan |
last post by:
Hi,
has anybody come across a solution to running an Access97 database on
Windows XP. The situation I have is an Access 97 database that runs
perfectly from Win95/98 clients running Access97, the database sits on
a Windows2000 server to which everyone has full NTFS access rights.
The problem is the WinXP and Win2k clients which appear to run fine
(also running Access97) in reading any existing data but as soon as
you attempt to edit a...
|
by: mariantrygg |
last post by:
Set qdf = dbs.QueryDefs("qryUpdate_OMNIS_F_ST_Transactions") 'append
qdf.Parameters(0) = DMax("STTR_SEQ", "CopyOMNIS_F_ST_Transaction")
qdf.Execute dbSeeChanges
This gives me an error 3146 "Invalid character value for cast
specification"
I think that the field I am using the parameter on is an IDENTITY
field in the remote db and my local copy of it (which used to be and
OMNIS db, hence the name!) is using a Long.
|
by: Rebecca |
last post by:
I've posted this in the middle of an older thread but it seems to have
gone unnoticed. I apologize for repeating myself.
We are converting an existing Access97 split database to an Access front
end with a SQL Server back end so that its users, who live all over the
state, can all use it without mailing the back end back and forth
throughout the year.
I am trying to set up the installation package with the ODE tools so
that the users...
|
by: George |
last post by:
I have an application in Access97 which operates very normal on pc's
with
Win98 S.E. as an operating system.When I install the same application
on a PC
wich runs Windows 2000 Server (and Microsoft Access97) it crashes all
the
time without an error.There is no specific event which generates the
crash of
the application.It simply closes!
|
by: lesperancer |
last post by:
SELECT distinct b.t_orno, b.t_pono
FROM tblMonthlyBooking AS b, tblFilterDate, tblFilterDate AS
tblFilterDate_1
WHERE (((b.t_yearMonth) Between . And
.));
tblMonthlyBooking is a sql server table, 200K rows, yearMonth is an
indexed long integer
the primary key is t_orno, t_pono
| |
by: lesperancer |
last post by:
I've got a sql server view that returns data, as a linked table to
access97 (qryPlannedPurPT)
this link table is used in an access query (qryPlannedPUR) that uses
all of the linked table fields and adds a couple of calculated fields
when I create a second query using qryPlannedPUR that adds a specific
WHERE clause
I may or may not get the correct resultset
I always get the correct number of rows, but one of the row contains
the wrong...
|
by: lesperancer |
last post by:
you start with a small application in access97, then you have more
modules and more...
and you reach the point where tables like 'item' and 'employee' reach
the limit and you
know there's more indexes required for RI to come
does creating a RI programatically instead of the relationship window
still consume one of the 32 indexes ?
does access2000 / 2003 allow more indexes per table ?
|
by: lesperancer |
last post by:
currently using access97 to link to sql7 tables
sql7 is running on NT4 and terminal server 2000
in the process of upgrading hardware and software to latest stable
versions
citrix - windows 2003
sql server 2005
office 2003 (maybe 2007)
first step is to implement sql server 2005 on windows 2003 and have it
|
by: Ramchandar |
last post by:
Hi,
I am creating reports using VBA code.
I have the same query in a querydef residing both in Access97 and Access2003. The result of this querydef is then moved to a table in Access97 and Access2003 respectively. The table in Access97 returns 874 rowcount, table in Access 2003 returns 1050 rowcount. In both the case the querydef is retrieving from the same database which resides in SQL Server 2003.
I executed the application Access97 and...
|
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: 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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
| |