pasting rows from excel - pass-through query called twice!

S

steph

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top