Connecting Tech Pros Worldwide Forums | Help | Site Map

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

Rich P
Guest
 
Posts: n/a
#1: Aug 12 '08
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 ***

ragtopcaddy via AccessMonster.com
Guest
 
Posts: n/a
#2: Aug 13 '08

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


Thanks Rich. I'll give that a try.

Bill

Rich P wrote:
Quote:
>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

Closed Thread