I am having a problem saving checkbox values to an MSAccess table. See code below for snippets. Its a fairly long complex form with a number of checkboxes but I'm having the same problem with all of them. I get an error on the line with:
MM_editCmd.Execute
stating "Microsoft JET Database Engine error '80040e14'
Syntax error in UPDATE statement. "
I've tried every permutation of checking the value of the checkbox I can think of and they all error out. If I simply hard code:
kcheckboxExo = True
it works fine.
HELP!
Kim King
<input <%If (cstr((rsWorks.Fields.Item("ExhibOnly").Value)) = cstr(true)) Then Response.Write("checked") : Response.Write("")%> type="checkbox" name="checkboxExo" value="ExhibOnly">'then check for value:if len(request.form("checkboxExo"))>0 then kcheckboxExo = Trueend if'sql: MM_editQuery = "update webworks set ExhibOnly="&kcheckboxExo&", CustomSort='"& kcustsort & "', Status="&kcheckboxstat&" where webworks.originalworknumber = " & MM_recordId &";"'data: Set MM_editCmd = Server.CreateObject("ADODB.Command") MM_editCmd.ActiveConnection = MM_editConnection MM_editCmd.CommandText = MM_editQuery MM_editCmd.Execute MM_editCmd.ActiveConnection.Close
I would then also ensure that this variable is declared as a Boolean value, otherwise it may not be returning the true boolean values for True and False.
If this fails I would suggest changing the field on the database itself to a small integer and simply writing 0 or 1 to it. It generally works better and you can read and right the values directly to the checkbox.
Adding the false statement fixed the straight checkbox problem, but there are two that are numeric fields (1 or 0) that I'm having trouble with the code below. If I don't make it cstr(kcheckboxwkstat), I get a type mismatch error.
Thanks,
Kim
kcheckboxwkstat = request.form("checkboxwkstat")if cstr(kcheckboxwkstat)="1" then kcheckboxwkstat=1else kcheckboxwkstat=0end if
What dan_neal has put is correct, a alternative solution is to lose the "Value=" part all together so that the checkbox just return a 0 or 1.
Whichever suits you best.
0
Featured Post
Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.
Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc.
In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
Beware when using the ListIndex and the Column() properties of a listbox in Access 2007. A bug has been identified in the Access 2007 listbox code which can cause the .ListIndex property to return a -1, and the .Columns(#) property to return a NULL…
How can you see what you are working on when you want to see it while you to save a copy?
Add a "Save As" icon to the Quick Access Toolbar, or QAT.
That way, when you save a copy of a query, form, report, or other object you are modifying, you…