Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-06-29
6
Medium Priority
?
336 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
4 Comments
 
LVL 54

Accepted Solution

by:
nico5038 earned 1000 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 1000 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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

824 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