This one?
https://learn.microsoft.com/en-us/office/vba/api/access.docmd
Issue to code
Hi,
To code below, what should DoCmd be declared?
Dim StrSQL As String
Dim InDate As Date
Dim DatDiff As IntegerInDate = Me.FromDateTxt
StrSQL = "INSERT INTO Test (Start_Date) VALUES ('" & InDate & "' );"
DoCmd.SetWarnings False
DoCmd.RunSQL StrSQL
DoCmd.SetWarnings True
10 answers
Sort by: Most helpful
-
-
Peter_1985 2,686 Reputation points
2021-05-03T05:30:52.217+00:00 Viorel,
Is there complete example to open Access table, clear details of table, in VBA? -
DBG 2,301 Reputation points
2021-05-03T14:48:05.56+00:00 Hi. DoCmd is an Application object. You don't declare it, like you would a variable. You just use it.
When you say "clear details of table," are you talking about deleting all the records?
-
Peter_1985 2,686 Reputation points
2021-05-05T02:28:26.407+00:00 Hi,
I've got following error,
]1
due to For Each line below. Please helpPublic Function TblExists(ByVal strTableName As String) As Boolean
Dim tblN As Object
TblExists = False
For Each tblN In Adb.TableDefs
If tblN.Name = strTableName Then
TblExists = True
Exit For
End If
Next tblN
End FunctionDim Adb As Object: Set Adb = CreateObject("Access.Application") Call Adb.OpenCurrentDatabase(F1) Adb.Visible = False
-
DBG 2,301 Reputation points
2021-05-05T03:10:34.637+00:00 Try replacing this line,
For Each tblN In Adb.TableDefs
With these ones:
Dim db As DAO.CurrentDb
Set db=CurrentDb()
For Each tblN In db.TableDefs