Issue to code

Peter_1985 2,466 Reputation points

To code below, what should DoCmd be declared?

Dim StrSQL As String
Dim InDate As Date
Dim DatDiff As Integer

InDate = Me.FromDateTxt

StrSQL = "INSERT INTO Test (Start_Date) VALUES ('" & InDate & "' );"

DoCmd.SetWarnings False
DoCmd.SetWarnings True

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
797 questions
{count} votes

10 answers

Sort by: Most helpful
  1. Ken Kam Hung, Lin 91 Reputation points
    0 comments No comments

  2. Peter_1985 2,466 Reputation points

    Is there complete example to open Access table, clear details of table, in VBA?

    0 comments No comments

  3. DBG 2,311 Reputation points

    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?

    0 comments No comments

  4. Peter_1985 2,466 Reputation points

    I've got following error,
    due to For Each line below. Please help

    Public 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 Function

    Dim Adb As Object: Set Adb = CreateObject("Access.Application")  
    Call Adb.OpenCurrentDatabase(F1)  
    Adb.Visible = False  
    0 comments No comments

  5. DBG 2,311 Reputation points

    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

    0 comments No comments