Solved

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

Posted on 2006-06-29
6
271 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
  • 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now