[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Compile error when calling a sub from a form sub

Posted on 2009-04-27
Medium Priority
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

Kelvin Sparks earned 2000 total points
ID: 24240966
Try using Call DeleteData(strTable, myDate)

Instead of DeleteData(strTable, myDate)


Author Comment

ID: 24240985
Great! It works. Thanks

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

872 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