Compile error when calling a sub from a form sub

Posted on 2009-04-27
Last Modified: 2013-11-28
Hi Experts,

I have a form with a cancel button. I want to erase some data from my table if user clicks cancel. So in the sub cmdCancel_Click(), I call the sub DeleteData as

DeleteData(strTable, myDate)

But it shows as a compile error: expected: =

I don't understand why this happens as the DeleteData sub is declared in a common module as public.

Can anyone help?
Public Sub DeleteData(TableName As String, aDate As Date)

    Dim strSQL As String

    strSQL = "DELETE * FROM " & TableName & " WHERE Cstr([Date]) = '" & aDate & "'"

    CurrentDb.Execute (strSQL)

End Sub

Open in new window

Question by:LizzJ
    LVL 22

    Accepted Solution

    Try using Call DeleteData(strTable, myDate)

    Instead of DeleteData(strTable, myDate)


    Author Comment

    Great! It works. Thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Suggested Solutions

    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now