Solved

Checkbox in a datasheet - cheating with a UNIQUES recordsource query?

Posted on 2006-06-29
6
310 Views
Last Modified: 2008-03-10
I have a datasheet on a form that contains a checkbox.  

For one condition, the datasheet's recordsource is based on a UNIQUES query, thus the recordset is not updatable.  Therefore, the checkbox is not functional.  The UNIQUES query is required as the the condition produces duplicate results.  There are also two JOINS in the query and I have selected the Dynaset "Inconsistent Updates" option in the query and in the datasheet.

Can anyone suggest a method (or a cheat) to allow the checkbox to be "checked" even in this condition?  I do note that the double-click event is functional, single-click is not.

Any creative ideas?


Thanks,

Mark
0
Comment
Question by:markp99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
6 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 250 total points
ID: 17013539
The work around I see is to change the UNIQUES query into a maketable (or append) query to fill a temp table.
When checked you can use queries to manage the result in the normalized tables.
There's however the danger of intermediate updates (deletes) on the source tables, thus the only ultimate solution would be to create a main/subform to avoid the readonly recordset and to handle the rows properly.

Nic;o)
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 17014936
Hi Mark,
Creative ideas huh....lol, lots.
How about this.

Seeing as how your datasheet view is acting more like a display than a selection option..Switch it's view to continuous forms. Put a button at one end beside the checkbox. put this as the on_click event of the button

Private Sub Command18_Click()
Dim strSQL As String
Dim lnID As Long
lnID = Me.ID.Value    '<----ID field of the displayed record
strSQL = "Update Orders set Check = -1 where ID = " & lnID   '<-----Replace table and field names with yours
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
   
End Sub
This will set your checkbox for that individual record.
J
0
 
LVL 34

Expert Comment

by:jefftwilley
ID: 17014947
One more thing...you'll probably need a
me.requery
right before you end sub

J
0
 
LVL 34

Assisted Solution

by:jefftwilley
jefftwilley earned 250 total points
ID: 17014957
IF you want to be able to click again and it goes back to "unchecked" then you'll want to make the code above based on an "IF"

something like this

Private Sub Command18_Click()
Dim strSQL As String
Dim lnID As Long
lnID = Me.ID.Value
blTrue = DLookup("Check", "Orders", "ID = " & lnID)
If Not blTrue Then
    strSQL = "Update Orders set Check = -1 where ID = " & lnID
Else
    strSQL = "Update Orders set Check = 0 where ID = " & lnID
End If
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
Me.Requery
End Sub
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

740 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