473,395 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Conflict with Record Counter and Print check box selector

112 100+
Conflict with Record Counter and Print check box selector
I have created a new navigation bar for my form, as the one Access provides is very small and hard to read. The problem is with the Record counter code is conflicting with a Print Selector button that already exists on my form. I use the Print Selector button when I have filtered the form down to say 20 records that I want. Then when I click the button, it automatically checks a bound check box for all 20 records, so I don’t have to do it one by one. I use this check box as a record selector to then run reports or do more filtering. Now when I click the button it only checks the first record but not the rest. I did not write the code for the Print Selector button and do not entirely understand how it works. But, I think I know what the conflict is I just don’t know how to fix it. Both codes run through the record set to select records that have been filter, one counts them the other updates. The line that causes the problems is line 3 in the Record Counter, but if I take it out it does not work properly. The codes are below.

Record counter: (in On Current of Form)
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. With Me
  3.      If RecordsetClone.RecordCount > 0 Then .RecordsetClone.MoveLast
  4.     !txtRecordDisplay = "" & .CurrentRecord & " of " & .RecordsetClone.RecordCount
  5.     !cmdFirst.Enabled = .CurrentRecord <> 1 'And Not .NewRecord
  6.     !cmdPrevious.Enabled = .CurrentRecord <> 1 'And Not .NewRecord
  7.     !cmdNext.Enabled = .CurrentRecord <> .RecordsetClone.RecordCount 'And Not .NewRecord
  8.     !cmdLast.Enabled = .CurrentRecord <> .RecordsetClone.RecordCount 'And Not .NewRecord
  9. End With
  10. End Sub
Print Selector button:
Expand|Select|Wrap|Line Numbers
  1. Private Sub filtog_Click()
  2. On Error GoTo Err_filtog_Click
  3. Set DBase = CurrentDb()
  4. Set Fc = Forms![frmDescription]
  5. Set filttogrecset = Fc.RecordsetClone
  6.  
  7.    If filttogrecset.EOF Then
  8.        filttogrecset.MoveFirst
  9.    End If
  10.  
  11. Dim Searcher As Integer
  12. Searcher = 0
  13.  
  14. Do While Not filttogrecset.EOF
  15. Me.Bookmark = filttogrecset.Bookmark
  16.  
  17. filttogrecset.Edit
  18.  
  19. filttogrecset!Search = True
  20.  
  21. filttogrecset.Update
  22. Searcher = Searcher + 1
  23. filttogrecset.MoveNext
  24.  
  25. Loop
  26.  
  27. filttogrecset.Close
  28.  
  29. DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
  30.  
  31. txt_ToggleCounter.Value = CStr(Searcher) + " item(s) are toggled"
  32. Exit_filtog_Click:
  33.     Exit Sub
  34.  
  35. Err_filtog_Click:
  36.     MsgBox Err.Description
  37.     Resume Exit_filtog_Click
  38.  
  39.  
  40. End Sub
I have look at changing both codes but have had no luck. Does anyone have any suggestion on how to resolve this with changes to either of the codes?
Jun 26 '13 #1
7 1533
zmbd
5,501 Expert Mod 4TB
You haven't mentioned which version of Access nor if this is a recent move from an older version to a newer version.

Also, if you open the form using the "old" method, does the code work?

How do you call this form vs. how you used to call the form?

Your first code block, "Form_Current," is toggleing the state of the record-navigation/movement buttons. It doesn't appear to be altering the value of the [Search] field which the second block appears to be doing.

The second code block, "filtog_Click" are you getting any error messages from this when you click on the code?

Also try this:
Comment out line 29 by placing a single quote ( ' ) in front of it, the line should turn green if the defaults are used for font colours. I don't want to delete this line of code yet, just idle it for the moment.
Now Right below that line enter:
Expand|Select|Wrap|Line Numbers
  1. me.refresh
This should show only the changes to the records made within this code.

Let us know what happens.
Jun 26 '13 #2
Redbeard
112 100+
Ok, I will try an explain better. First I am using Access 2010 and have been for a few months now. Everything was working fine then I created the new record navigator to replace the small one Access provides at the bottom of the screen. It has a forward, back, move last, move first and new record buttons with an unbound text box for the record count. It also worked with no issues on my form. However, when I filtered down to 20 records that I would like to print and click the Print Selector button, it just checked the last records check box and not all of them. When I turn the new navigation bar off, by placing single quotes on every line of the code, the Print Selector button works and puts a check in all 20 records check box. I do not get an error message when this happens, it just does not work.

So since the code on the Print Selector button runs through each record with (.MoveNext) and put a check in the ones that are currently filter, and the record count box uses (.MoveLast) when counting… I am assuming that when I click the Print Selector button it moves to the next record then the record count code counts and moves to the last and only the last one gets checked.

I tried what you suggestion zmbd by taking out line 29 and putting in the requery but nothing changed.

I have been looking at alternative codes for both but nothing seems to work. Any suggestions?
Jun 27 '13 #3
zmbd
5,501 Expert Mod 4TB
Why are you using recordsetclone in the first block and not recordset. In this case you are looking at the actual position of the current record as indicated by the cursor. One normally uses the clone when you don't need to have the form synced with the record operations (one can ofcourse sync via the bookmark as needed).
So let's try something very simple within the first code block and simply remove "clone."

If that doesn't fix it then I'll need to really read thru things carefully and maybe build a test database to see if I can replicate what is happening to you.
Jun 28 '13 #4
Redbeard
112 100+
Hi zmbd. I tried removing “clone” as you suggested and it takes me to the last record on load. When I try to move off that record it gives me a message that “I can’t go to that record and puts me back to the last one. After doing a bit more hunting around on the internet I have clean up my code and used what seem to be more stander as I have found multiple post of similar code (see below). I also found a couple of post that say you need to use “RecordsetClone” to get an accurate count… not sure if that’s true but it does seem to work well. However, I still get the conflict when I try and use my Print Selector button. Since I think that I am at a dead end with changing the record count I am now trying to figure out a way to modify the Print Selector button code. Any other suggestion are appreciated.

Expand|Select|Wrap|Line Numbers
  1. Dim rst As DAO.Recordset
  2.     Dim lngCount As Long
  3.  
  4.     Set rst = Me.RecordsetClone
  5.  
  6.     With rst
  7.         .MoveFirst
  8.         .MoveLast
  9.         lngCount = .RecordCount
  10.     End With
  11.  
  12.     Me.txtRecordDisplay = Me.CurrentRecord & " of " & lngCount
  13.     Me.cmdFirst.Enabled = Me.CurrentRecord <> 1
  14.     Me.cmdPrevious.Enabled = Me.CurrentRecord <> 1
  15.     Me.cmdNext.Enabled = Me.CurrentRecord <> Me.RecordsetClone.RecordCount
  16.     Me.cmdLast.Enabled = Me.CurrentRecord <> Me.RecordsetClone.RecordCount
Jun 28 '13 #5
Redbeard
112 100+
So I have made some progress… I have added this to the Print Selector button code:
At the start
Expand|Select|Wrap|Line Numbers
  1. Me.txtRecordDisplay.Enabled = False
and at the end
Expand|Select|Wrap|Line Numbers
  1. Me.txtRecordDisplay.Enabled = True
And I have added this to the “On Current” of my form:
Expand|Select|Wrap|Line Numbers
  1. If Me.txtRecordDisplay.Enabled = True Then
with an "EndIf" at the bottom.

The “txtRecordDisplay” is my unbound textbox that displays my record count. The theory is that when the Print Selector button is click it disables the record count box before starting to move through the records and checking the boxes. When the “On Current” runs, it requires that box to be enabled to set the record count. So since the “On Current” is not running there is no conflict and the code should work! When all the boxes are checked it enables the textbox again.

So this is what actually happens… when I click the Print Selector button first time it does the same thing… checks the checkbox in only the last record. But when clear the checkbox and click the Print Selector button again it preforms the function as intended and check the check box in every record! So I am almost there, just need to figure out why it won’t do it the first time through? Any thoughts?
Jun 28 '13 #6
zmbd
5,501 Expert Mod 4TB
Ok, this is going to take more time to look at than I have at the moment. It's my day off and I have the four kids :-)
Love'em - but they take a lot of work and chasing after!
Jun 28 '13 #7
Redbeard
112 100+
No worries zmbd... I am just about to go off on a long weekend and will not be back to this till next Thursday. Enjoy the time with the kids.
Jun 28 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Michelle | last post by:
I have tried every variation of the "onchange" statement below without any actual reloading of the page. I am hoping that the PHP PRINT statement is constructed wrong, otherwise it is javaScript...
1
by: DD | last post by:
The following code sits behind a clickEvent my problem is two fold 1. I need to only allow the user to click the button once 2. I have used ClearForm() however this then stops the user from being...
1
by: Simon | last post by:
Dear reader, In case I work with two Forms and using the same Table but with other fields in the Forms, I have the following experience. After I change in one of the two Forms a field I can't...
1
by: Nothing | last post by:
I have a form that I turned off the nav buttons. I then create my own. The reason I do is that I cna then move the nav buttons any where I need to on the form. The only thing I can not figure...
17
imrosie
by: imrosie | last post by:
Hello, I've gone through the tutorials, and searched. Still I can't find a clear solution to my issue. I have a form with a subform that displays a listbox control called 'theOrderID'. I have...
8
Ali Rizwan
by: Ali Rizwan | last post by:
Here is the question. Write a program that will get a record of the student i.e. Name, Fathers Name, Degree Studying, Phone Number, and Date Of Birth and Then Show the record of the student? ...
6
by: Fresco | last post by:
Using Access 97, how do I avoid printing multiple copies of a check when the subreports used for the check stubs have multiple records (like when I want to pay several invoices with one check)? If I...
1
by: Michael R | last post by:
Hi All. I remember seeing a record counter in a report, something that shows line number in a report section. (group) Anyone knows about it? Michael.
2
by: Sam | last post by:
Is there a formula or easy way to add a record counter in Access to a query? I have a field that contains a file number this file. I want to add a counter like below. Field Name Field...
8
by: fish919 | last post by:
Hello All, I am having a little trouble with my database. The Database has a parent table with 5 or 6 children tables in it they are linked by a common id filed. The problem is that the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.