Solved

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

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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

751 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