Full Version: DoCmd.RunSQL without warning (append query)
UtterAccess Forums > Microsoft® Access > Access Forms
MrSiezen
Hi!
'd like to run the DoCmd.RunSQL command run without a warning that I'm about to append a x number of records. I'm aware of the function to disable warnings, but the problem is that if the query generates a 'real' error, no warning is shown as well.
Is there a more discrete way of doing this?
dannyseager
CurrentDB.execute "Your SQL",DbFailOnError
MrSiezen
Hmm that doesn't make a difference here, it still shows the same warning.
R. Hicks
Post your code ...
DH
MrSiezen
Here it is...
**********
Public Function SaveGasten(sNetwerk As String)
Dim IDBijeenkomst As Integer
IDBijeenkomst = DMin("[ID]", "TblDataBijeenkomsten", "[Datum bijeenkomst] >= Date() And [Netwerk] = '" & sNetwerk & "'")
DoCmd.RunSQL "INSERT INTO TblVerloopGasten ( MAINIDGast, IDBijeenkomst ) " & _
"SELECT TblData.MAINID, " & IDBijeenkomst & " AS IDBijeenkomst " & _
"FROM TblData " & _
"WHERE Tbldata.Status IN ('1', 'H', 'OK', 'H OK') AND TblData.Netwerknummer = '" & sNetwerk & "'", dbFailOnError
End Function
***********
dannyseager
I suggested using the CurrentDB.execute method.... try
!--c1-->
CODE
Public Function SaveGasten(sNetwerk As String)
Dim IDBijeenkomst As Integer
IDBijeenkomst = DMin("[ID]", "TblDataBijeenkomsten", "[Datum bijeenkomst] >= Date() And [Netwerk] = '" & sNetwerk & "'")
CurrentDB.execute "INSERT INTO TblVerloopGasten ( MAINIDGast, IDBijeenkomst ) " & _
"SELECT TblData.MAINID, " & IDBijeenkomst & " AS IDBijeenkomst " & _
"FROM TblData " & _
"WHERE Tbldata.Status IN ('1', 'H', 'OK', 'H OK') AND TblData.Netwerknummer = '" & sNetwerk & "'", dbFailOnError
End Function
BrianS
Just to add a small foot note
On order for CurrentDB.Execute to work, you must have a reference checked for Microsoft DAO 3.x Object Library.
to check you references use the Tools-->References menu in the any code window.
Alternatively you could use
CurrentProject.Connection.Execute "YourSQLHere"
This uses the ADO object library which is used by default in Access 2003
dannyseager
You dont in my copy of access XP.
Has this changed for 2003?
R. Hicks
In Access 2003 the default is DAO .. not ADO as in Access 2000 and 2002 ...
DH
dannyseager
Any idea why they changed it?
would have thought they would have changed it the other way as ADO is newer.
R. Hicks
Not really sure .. but in Access 2003 .. it automatically sets a reference to DAO 3.6 when the database is created.
DH
dannyseager
I guess they learned that for a lot of things you still need DAO.
R. Hicks
I agree ... DAO was slated to be dropped in a future version of Access .. but Microsoft has re-thought this and there are now no future plans to drop DAO ...
DH
BrianS
Thanks for pointing this out Ricky, I have not used Access 2003, I just assumed it followed suit with 2000 and 2002
MrSiezen
Oh I'm very sorry didn't see that, just saw the addition at the end.
That works fine, and I'm glad to see you learned something as well here...
dannyseager
you're welcome.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.