VBA syntax and other junk I don't know.

ggodwin

Registered User.
Local time
Today, 18:43
Joined
Oct 20, 2008
Messages
112
I have got this button event that is kicking off some action.
Is there a way that I can add to this?

Private Sub Update_Click()
'Delete old records from SkpiUpdate
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete [SkpiUpdate].* from [SkpiUpdate]"
DoCmd.SetWarnings True

'Import new records from Excel file into Table1
DoCmd.TransferSpreadsheet acImport, 8, "SkpiUpdate", "K:\_DENSO QRE\SKPI PARTS RETURN\Copy of DownloadNCPartListServlet.xls", True, ""
End Sub​

After what you see listed. I would like to execute a couple queries that I have save and I don't know the best way to do this?

The query names are
Query1 » CreateScrapRecordTag
Query2 » NewRecords
Query3 » DeletedRecords

Is there a way to add these to the end?
 
Howzit

try the following

Code:
Private Sub Update_Click()
'Delete old records from SkpiUpdate
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete [SkpiUpdate].* from [SkpiUpdate]"


'Import new records from Excel file into Table1
DoCmd.TransferSpreadsheet acImport, 8, "SkpiUpdate", "K:\_DENSO QRE\SKPI PARTS RETURN\Copy of DownloadNCPartListServlet.xls", True, ""

docmd.openquery CreateScrapRecordTag
docmd.openquery NewRecords
docmd.openquery DeletedRecords


DoCmd.SetWarnings True
End Sub

or possibly

Code:
Private Sub Update_Click()
'Delete old records from SkpiUpdate
Currentdb.execute "Delete [SkpiUpdate].* from [SkpiUpdate]"

'Import new records from Excel file into Table1
DoCmd.TransferSpreadsheet acImport, 8, "SkpiUpdate", "K:\_DENSO QRE\SKPI PARTS RETURN\Copy of DownloadNCPartListServlet.xls", True, ""

Currentdb.execute CreateScrapRecordTag
Currentdb.execute NewRecords
Currentdb.execute DeletedRecords

End Sub
 
The first set of code gave me the Run-Time error 2496 "The action or method requires a Query name or argument"

The 2nd Set gave me
Run-Time Error 3078

Jet db engine could not find the table make sure it exist or spelled correctly.

I checked the spelling and they are good.
 
Howzit

Sorry you need to encase the queries in "".

Been a long day - I'm off to bed now.

Code:
Private Sub Update_Click()
'Delete old records from SkpiUpdate
DoCmd.SetWarnings False
DoCmd.RunSQL "Delete [SkpiUpdate].* from [SkpiUpdate]"


'Import new records from Excel file into Table1
DoCmd.TransferSpreadsheet acImport, 8, "SkpiUpdate", "K:\_DENSO QRE\SKPI PARTS RETURN\Copy of DownloadNCPartListServlet.xls", True, ""

docmd.openquery "CreateScrapRecordTag"
docmd.openquery "NewRecords"
docmd.openquery "DeletedRecords"


DoCmd.SetWarnings True
End Sub
 

Users who are viewing this thread

Back
Top Bottom