Import Record count (1 Viewer)

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:57
Joined
Aug 30, 2003
Messages
36,124
Post 15 was moderated, I'm posting to trigger email notifications.
 

starter

New member
Local time
Today, 11:57
Joined
Sep 15, 2019
Messages
9
maybe no record, because you already appended it before.
delete the record from mssql and try again.

btw, remove the "On error resume next", so you will see what error you have.

I deleted the records from mssql.

I removed "On error resume next".

When I select the file for import, I get this error:
Run-time error '3061':
Too few parameters. Expected 1.

Issue appears with:

Code:
'attempt to append import to MSSQL table
Dim lngRecordsAffected As Long
DoCmd.SetWarnings False
    DoCmd.OpenQuery "qryClearOldTransactions", acViewNormal
    'DoCmd.OpenQuery "qryAppendCCTransactions", acViewNormal
    With CurrentDb.QueryDefs("qryAppendCCTransactions")
        [COLOR="Red"].Execute[/COLOR]
        lngRecordsAffected = .RecordsAffected
    End With
DoCmd.SetWarnings True
MsgBox DCount("*", "tCCTransactions") & " records found " & vbCrLf & lngRecordsAffected & " records were imported"
 

isladogs

MVP / VIP
Local time
Today, 17:57
Joined
Jan 14, 2017
Messages
18,209
Post #22 also moderated. Now approved.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:57
Joined
Feb 28, 2001
Messages
27,146
Don't know if this will work for this case, but instead of doing a DoCmd.whatever for the append, do a CurrentDB.Execute of the same append query. If that query works in "Execute" context, you can do a test of CurrentDB.RecordsAffected as the next instruction to determine how many records were ACTUALLY appended. Again, don't do math to find the answer. Just ask Access to tell you.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:57
Joined
May 7, 2009
Messages
19,229
the error means, the your query does not run.
try to run it on it's own.
open it from navigation panel and run it.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 11:57
Joined
Feb 28, 2001
Messages
27,146
OK, my error of omission, .Execute works for QueryDef objects too. The only thing I can add to arnelgp's comment is to make the .Execute have parameter dbFailOnError as a parameter, just to give it one.

If arnel is right (and he VERY often is) then the query failed. That parameter is benign in this context, since it says "fail if something goes wrong" and it was already failing anyway so... just gilding the lily.

If this is a debugging issue then you don't want to turn off warnings around this code. you WANT it to bomb so that you can get a spot notification and can examine things at the point of the error. If you are doing this on a production copy of your code then you have other issues to consider, but if this is a private development copy then you should be OK. Also, using dbFailOnError is actually nicer because it is more likely to clean up after itself and not leave a half-updated table sitting around after a failure.
 

moke123

AWF VIP
Local time
Today, 12:57
Joined
Jan 11, 2013
Messages
3,912
Just noticed in your original posting that you did not declare Option Explicit.
It would probably be wise to do so given the long names you have used.
 

Users who are viewing this thread

Top Bottom