473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
1 1679
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Shufen | last post by:
Hi, I'm a newbie that just started to learn python, html and etc. I have some questions to ask and hope that someone can help me on. I'm trying to code a python script (with HTML) to get...
4
by: Steve | last post by:
I have a products table where the PK is ProductID. Also have the standard Orders table and OrderDetails table. I created a query that joins the Orders table and OrderDetails table. The query...
3
by: Ray | last post by:
I have below query in Access 97 but it is not updateable by entering or editing data in the query. Can someone advise how to modify it to be updateable one. SELECT .PCode, .Model, .Description,...
1
by: Edward | last post by:
I've recently migrated the back end of one of my client's applications from Access to SQL Server. One of the forms is based on an Access query thus: SELECT dbo_tblDistributionDetail.*,...
5
by: Jack | last post by:
TblProduct ProductID ProductName Selected (Y/N) TblOrder OrderID CustomerID TblOrderDetail
8
by: Jim in Arizona | last post by:
I've been using an example out of a book to be able to edit the rows in a database. I am getting the following error: ========================================================...
3
by: Mike | last post by:
Hi all Can't seem to find the answer I'm looking for and I tried just about everything I've read on here already. Maybe someone can help out. I need a list of medications to display and then...
8
by: Sid | last post by:
I hope someone could help me with this. I am trying to setup a criteria to decide when to allow/not allow user to click on the check box. logically it looks simple but I am not able to...
2
by: jghouse | last post by:
Everyone, Hopefully you can help me with a little problem I am having. I have a need to limit the records shown in a form by a few different criteria. I also need these records to be editable....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.