Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL vs Recordsets for unbound operations

Status
Not open for further replies.

NXMold

Technical User
Jul 22, 2008
104
I am setting up a purchase order system and have decided to add new records using VBA, and also deleting them if certain conditions are not met.

I started to implement this with docmd.runsql and warnings turned off, but now I wonder if its better to use recordsets, particularly in case of an error.

Any comments on the reletive merits of each approach?
 
I like Execute best.

Code:
Set db=CurrentDB

db.Execute strSQL, dbFailOnerror

lngRecords=db.RecordsAffected

Or


Code:
    Set db = CurrentDb

    Set qdf = db.CreateQueryDef("", SQLText)
    qdf.Parameters!txtEvent = Trim(frm!txtEvent)
    qdf.Parameters!dteCRDate = Now()
    
    qdf.ReturnsRecords = False
    
    qdf.Execute dbFailOnError
    
    intResult = qdf.RecordsAffected

 
I was unaware of that method, thanks.
 
How are ya NXMold . . .

The best and the fastest methood for adding new records is a [blue]bound form![/blue] Why is this not a consideration? ... it would certainly circumvent having to generate the code that access already does for you!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Or if you like doing it with ADO:

CurrentProject.Connection.Execute "DELETE * FROM MyTable"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top