473,773 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

pasting records in datasheet-form: pass-through called twice ?

Hi all,

I have an Access2002 form in in datasheet view. Column "CMP" is locked
to user input, instead it is filled automatically by this function:

===
Private Sub Form_BeforeInse rt(Cancel As Integer)
On Error GoTo Form_BeforeInse rt_Err
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordse t("q_compoundna me", dbOpenDynaset)
rst.MoveFirst
CMP = rst![compoundname]
rst.Close

Form_BeforeInse rt_Exit:
Exit Sub

Form_BeforeInse rt_Err:
MsgBox Error$
Resume Form_BeforeInse rt_Exit

End Sub
===

"q_compound name " is a pass-through query to an oracle database, that
returns a value based on an oracle sequence like 'A0001', 'A0002',
'A0003', etc.

When inserting records manually, this works fine.

Nevertheless, there's a problem when pasting records from excel: then
the counter is increased by 2 with any row like 'A0004', 'A0006',
'A0008', etc. To me this indicates that the pass-throug query is called
twice per row.

It's vital that the numbers are increased only by 1, also if rows are
inserted from excel, which happens quite often.

Why does it make a difference, when rows are copied from excel? Is
there anything I can do to change the current behaviour of my form?

Thanks for any input,
Stephan

Dec 20 '05 #1
2 1713
On 20 Dec 2005 08:20:12 -0800, "steph" <st*******@gmx. net> wrote:
Hi all,

I have an Access2002 form in in datasheet view. Column "CMP" is locked
to user input, instead it is filled automatically by this function:

===
Private Sub Form_BeforeInse rt(Cancel As Integer)
On Error GoTo Form_BeforeInse rt_Err
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordse t("q_compoundna me", dbOpenDynaset)
rst.MoveFirst
CMP = rst![compoundname]
rst.Close

Form_BeforeIns ert_Exit:
Exit Sub

Form_BeforeIns ert_Err:
MsgBox Error$
Resume Form_BeforeInse rt_Exit

End Sub
===

"q_compoundnam e " is a pass-through query to an oracle database, that
returns a value based on an oracle sequence like 'A0001', 'A0002',
'A0003', etc.

When inserting records manually, this works fine.

Nevertheless , there's a problem when pasting records from excel: then
the counter is increased by 2 with any row like 'A0004', 'A0006',
'A0008', etc. To me this indicates that the pass-throug query is called
twice per row.

It's vital that the numbers are increased only by 1, also if rows are
inserted from excel, which happens quite often.

Why does it make a difference, when rows are copied from excel? Is
there anything I can do to change the current behaviour of my form?

Thanks for any input,
Stephan


I don't know why for sure, but any code that depends on how many times an
Access event should fire is generally unreliable. You could try an Oracle
trigger instead of an Access event, but the real "right" way to do this is to
have data entry batch tables, and generate the sequence numbers when the batch
is posted to the main table.
Dec 20 '05 #2
Hi Steve,

Could you describe to me the scenario with batch tables in more detail?
How would you post to the main table - via an append-query on the batch
table?

Thanks,
Stephan

Dec 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2284
by: M Stery | last post by:
Have two base queries used for mailing labels with id,name,address,city,state,zip that are combined via a union query. One base query uses home address; the other base query uses biz address. I only want one label per person. In a few cases, I have a record with both a home address and a biz address, which I don't want in the labels. How or can I make the union query omit an id in the biz address base query IF that same id has a record in...
6
1377
by: David | last post by:
One of my farm livestock app customer wants me to tweak the system so he can record where every animal is, and has been while it was on his farm. .. Example - heifer X was in top shed from 01/01/03 to 01/01/04 then west field from 01/01/04 to 01/05/04 then etc etc Cattle could be in groups of 30 or 40 but individual animals may not always be in the same group.
3
2305
by: Mike | last post by:
Using MS Access XP standard install (no Jet or MDAC updates applied yet) as front end, MySQL 4.0 as backend and MySQL ODBC connector version 3.51. When pasting multiple records into the database either in a form or directly in the table, all records / fields display #deleted in each column. This only happens when pasting multiple records, if a single record is pasted, the #deleted comment does not appear. When I refreash the view, the...
3
1226
by: TM | last post by:
Is there any way that I can take the records from a datagrid and paste them into an Excel sheet, then print preview or print the sheet ? Is there any way I can sort the sheet before I print it ? Thanks all -- Tony
2
1822
by: Steve Cartnal | last post by:
I need to copy records from several different tables into one text file. Although the tables have many common fields, they also contain several that are different from table to table. I can copy and paste the dissimilar records manually into the text file, so it would seem that should be possible to do programatically. I set up export specifications for each of the twelve tables and tried to export each to the same text file. This...
11
3680
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night) and the 'employee name'. There is another table which assigns an ID to the Shifts, i.e. 1,2 and 3 for morn, eve & night shifts respectively. From the mother table, the incentive is calculated datewise for each employee as per his shift duty. In...
4
2756
by: Roger | last post by:
on sql 2005, I've got a view with select permission granted, the view just "select * from table" using odbc in access97, I linked this view and I create a query to retrieve certain fields the query properties are 'no locks' and dynaset record type but just executing the query as a datasheet, locks some records in the original sql server table is this how it should work ? seems to me that it should not lock anything
21
1915
by: rfdjr1 | last post by:
I'm using Access 2000. I have a raher simple database of my CD collection, with just three fields, Artist, Album Title and Type of Music. While going to update it today with a couple new CD's, I noticed that if I sort alphabetically by Artist it have 387 records but if I sort by Album Title it shows 393 records. Any idea why this would be? And I know of at least two titles that don't show up when I look for them under the Artist sort....
1
2545
by: Gord | last post by:
Using VB, when records are brought up in datasheet view (either a query or table), is it possible to highlight (or in some way visually flag) certain records? If so, how is this 'highlighting' accomplished? Note that the records would most likely not be contiguous. The purpose being to bring those records to the users attention when required. Thanks, Gord
16
27079
by: BNW | last post by:
I need help in finding out why I am not getting any data in my query. When I select all the fields in one table in my query grid and run it, the data is there. However, when I try to do it using to related tables and pull fields from both table in my query rid and run the query, data from both related tables are not showing in my query datasheet. What is the problem? The relationship line in my query is showing that the table are linked....
0
9621
marktang
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...
0
10264
Oralloy
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...
0
9914
tracyyun
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...
0
8937
agi2029
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...
1
7463
isladogs
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...
0
5355
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...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.