mgmercurio
Member
- Local time
- Today, 02:26
- Joined
- Jan 18, 2021
- Messages
- 55
Let me try..... stand byCan you compile your project?
Ill give it a shot....stand by....Try:
Cheers,Code:Me.Dirty=False Call fncUpdateTblAttachments() Me.Requery
Vlad, This didn't work...I tried it in the AfterUpdate code and also tried putting it in the function....still didnt work. I can tell you that it is definitely has something to do with the number of checkboxes and the Function code. I also tried many variations in the function as well as changing the chkbox names...some examples below....nothing worked.Ill give it a shot....stand by....
I don't think it has anything to do with looping and/or iterations, the error is caused by Access seeing that the displayed data has been changed by another process (the update statement in the function). Try please to remove the code you have in the Form Load event (which is the one that initially populates the checkboxes and add the lookup expressions you had for each of the checkbox control sources. In the AfterUpdate events leave the latest code I've sent you (the one with me.requery at the end).Vlad, This didn't work...I tried it in the AfterUpdate code and also tried putting it in the function....still didnt work. I can tell you that it is definitely has something to do with the number of checkboxes and the Function code. I also tried many variations in the function as well as changing the chkbox names...some examples below....nothing worked.
The first snipit is original:
Dim i As Integer
'the sample also assume you have 4 checkbox
For i = 1 To 4 Step 1
Me("Chkbox" & Format(i, "00")) = DLookup("AttachFile", "tbl_Attachments", "AttachmentID = " & i)
Next
Dim i As Integer
'the sample also assume you have 4 checkbox
For i = 0 To 4 Step 1 <-----Also tried 1 to 5 Step 1
Me("Chkbox" & Format(i, "00")) = DLookup("AttachFile", "tbl_Attachments", "AttachmentID = " & i) <------ Tried many combinations of 00 i.e. 01, 11, 1, etc....
Next
Tried changing the chkBox names to chkbox00,chkbox01,chkbox02,chkbox03,chkbox04 or chkbox11, chkbox21, chkbox31, chkbox41, chkbox51
Nothing worked here either.
I realize my attempts to fix it was just completely off track...but not knowing how to code made me just take shots in the dark at it.
However, I do understand it does have something to do with the iterations and number of checkboxes. I also understand Anrelgp's code is calculating the number of boxes starting at 00....I just don't know what the calculation is....
-mgm
Private Sub arlRefreshCheckBoxes()
Dim i As Integer
For i = 1 To 5 Step 1 'adjust for your checkbox names and field
Me("Chkbox" & Format(i, "00")) = DLookup("TheCheckboxField", "tbl_Attachments", "AttachmentID = " & i)
Next
Call arlRefreshCheckBoxes
Me.Dirty=False
Call fncUpdateTblAttachments()
Call arlRefreshCheckBoxes
Sorry Vlad...I am just now seeing you had posted this earlier! I made an update above and it is now working. Thank you for everything brother...I certainly appreciate it ! -mgmSorry, my bad, forgot those were the unbound checkboxes used to edit the records. Lets try this:
1.Make the checkboxes unbound again (sorry)
2.In the form's module add this sub:
Code:Private Sub arlRefreshCheckBoxes() Dim i As Integer For i = 1 To 5 Step 1 'adjust for your checkbox names and field Me("Chkbox" & Format(i, "00")) = DLookup("TheCheckboxField", "tbl_Attachments", "AttachmentID = " & i) Next
3.In the Form's Load Event add:
Code:Call arlRefreshCheckBoxes
4.In the AfterUpdate events have:
Code:Me.Dirty=False Call fncUpdateTblAttachments() Call arlRefreshCheckBoxes
Please let me know how you make out. Ideally if you could prepare a sample db with just this form and the attacnments table and upload it here it could be much easier to help.
Cheers,
Yes they do update. But I will still implement your code if you think I should.Do the checkboxes get updated in the form after you run the updated function? I would recommend trying my latest suggestion as it would force a refresh of the checkboxes after the update.
Cheers,
Vlad
Im getting a compile error stating function or sub is not defined with regards to Call arlRefreshCheckBoxesSorry, my bad, forgot those were the unbound checkboxes used to edit the records. Lets try this:
1.Make the checkboxes unbound again (sorry)
2.In the form's module add this sub:
Code:Private Sub arlRefreshCheckBoxes() Dim i As Integer For i = 1 To 5 Step 1 'adjust for your checkbox names and field Me("Chkbox" & Format(i, "00")) = DLookup("TheCheckboxField", "tbl_Attachments", "AttachmentID = " & i) Next
3.In the Form's Load Event add:
Code:Call arlRefreshCheckBoxes
4.In the AfterUpdate events have:
Code:Me.Dirty=False Call fncUpdateTblAttachments() Call arlRefreshCheckBoxes
Please let me know how you make out. Ideally if you could prepare a sample db with just this form and the attacnments table and upload it here it could be much easier to help.
Cheers,
ahhhh yes I do....stand by.....Do you have it in the form's module (notice the Private in the declaration)? It cannot go in a standard module as Arnel's did.