Solved

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

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

630 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