By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,662 Members | 1,765 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,662 IT Pros & Developers. It's quick & easy.

Re: Checkbox is updateable in the query but not in the form

P: n/a
A good practice for editing data is to display the contents of the
particular record in an unbound form - the form is not connected to the
datasource/data table/query. You populate texttbox/checkbox controls
with the data from the record. You then perform your edits on that
record in the form and then submit the edits back to the table using sql
or DAO code.

Example using sql:

Private Sub cmdSubmitChanges_Click()
dim strSql As String

strsql = Update yourTable(fld1, fld2, fld3, ...) Set fld1 = '" & txtfld1
& "', fld2 = '" & txtfld2 & "', fld3 = " & chk1 & ", fld4 = #" & txtDate
& "#, ...
Where ID = " & txtID

Docmd.SetWarnings False
DoCmd.RunSql strSql
Docmd.SetWarnings True
End Sub

Note that you must delimit text values with single quotes 'textvalue',
date values with # pound symbol -- #4/1/2004#, and numbers/checkboxes
don't require delimiters. Don't forget the Where clause -- otherwise
you will end up updating your entire table to these values.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Aug 12 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Thanks Rich. I'll give that a try.

Bill

Rich P wrote:
>A good practice for editing data is to display the contents of the
particular record in an unbound form - the form is not connected to the
datasource/data table/query. You populate texttbox/checkbox controls
with the data from the record. You then perform your edits on that
record in the form and then submit the edits back to the table using sql
or DAO code.

Example using sql:

Private Sub cmdSubmitChanges_Click()
dim strSql As String

strsql = Update yourTable(fld1, fld2, fld3, ...) Set fld1 = '" & txtfld1
& "', fld2 = '" & txtfld2 & "', fld3 = " & chk1 & ", fld4 = #" & txtDate
& "#, ...
Where ID = " & txtID

Docmd.SetWarnings False
DoCmd.RunSql strSql
Docmd.SetWarnings True
End Sub

Note that you must delimit text values with single quotes 'textvalue',
date values with # pound symbol -- #4/1/2004#, and numbers/checkboxes
don't require delimiters. Don't forget the Where clause -- otherwise
you will end up updating your entire table to these values.

Rich
--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200808/1

Aug 13 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.