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

x
?
Solved

What's Wrong with this Code?

Posted on 2009-12-19
3
Medium Priority
?
227 Views
Last Modified: 2012-05-08
Experts,

In the attached code, I'm passing in a form object and then building a SQL string based on controls on that form.  The line with "VALUES" in it tells me that the object "won't support this property or method".  What am I missing?
Public Function nInsertTaskFromForm(taskForm As Form)

    'bc1
    
    If taskForm.Name <> "frmTask" Then
        nInsertTaskFromForm = -1
        Exit Function
    End If
    
        ' insert record into TASKS table
    sSQL = "INSERT INTO Tasks "
    sSQL = sSQL + "(taskForm.Tasks_Description"
    sSQL = sSQL & ",taskForm.Tasks_Short_Desc"
    sSQL = sSQL & ",taskForm.Tasks_Start_Date"
    sSQL = sSQL & ",taskForm.Status) "
    sSQL = sSQL & "VALUES('" & taskForm.txtTaskDesc.Text & "'"
    sSQL = sSQL & ",'" & taskForm.txtTaskShortDesc.Text & "'"
    sSQL = sSQL & ",#" & taskForm.txtStartDate & "#"
    sSQL = sSQL & "," & CStr(geWorkStatus.Due) & ")"
    gdbKnowledgeTracker.Execute sSQL
    
    nNewTaskID = nGetMaxRecordIDFromTable(gdbKnowledgeTracker, "Tasks", "Task_ID")
    

End Function

Open in new window

0
Comment
Question by:NigelRocks
3 Comments
 
LVL 3

Accepted Solution

by:
Paul Thompson earned 668 total points
ID: 26088940
The Line should read:-

SQL = sSQL & "VALUES('" & taskForm.controls("txtTaskDesc").Text & "'"


DJ
0
 
LVL 16

Assisted Solution

by:Robin
Robin earned 668 total points
ID: 26090104
Check for empty variables when building the SQL string.
You can replace empty ones with NULL (if allowed in table) or replace with a default value.
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 664 total points
ID: 26090868
Your taskForm parameter is declared as a generic Form which does not contain any controls. Declare it as a real form.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month19 days, 15 hours left to enroll

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