473,395 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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_BeforeInsert(Cancel As Integer)
On Error GoTo Form_BeforeInsert_Err
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("q_compoundname", dbOpenDynaset)
rst.MoveFirst
CMP = rst![compoundname]
rst.Close

Form_BeforeInsert_Exit:
Exit Sub

Form_BeforeInsert_Err:
MsgBox Error$
Resume Form_BeforeInsert_Exit

End Sub
===

"q_compoundname " 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 1690
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_BeforeInsert(Cancel As Integer)
On Error GoTo Form_BeforeInsert_Err
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb()
Set rst = db.OpenRecordset("q_compoundname", dbOpenDynaset)
rst.MoveFirst
CMP = rst![compoundname]
rst.Close

Form_BeforeInsert_Exit:
Exit Sub

Form_BeforeInsert_Err:
MsgBox Error$
Resume Form_BeforeInsert_Exit

End Sub
===

"q_compoundname " 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
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...
6
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...
3
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...
3
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 ?...
2
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...
11
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)...
4
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...
21
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...
1
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'...
16
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.