Stuart McLachlan
stuart at lexacorp.com.pg
Sat Feb 19 17:06:52 CST 2011
If I had to pick up your code from scratch and maintain it in the future: I actually find "If the user's Numlock preference doesn't match the current Numlock state, then toggle it" easier to follow :-). -- Stuart On 19 Feb 2011 at 6:58, Rocky Smolin wrote: > I think so. But I tend to write more verbose code out of self defense > because 6 months later it's much easier to figure out what I was > trying to do. > > So my code reads: > > "If the user's preference is to have the num lock on and it's off then > toggle the num lock off. Of the user's preference is to have the num > lock on and it's off, then toggle the num lock on." > > A bit redundant, I know, but just easier for me. Old guy, you > know.... > > Rocky > > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Bob > Gajewski Sent: Saturday, February 19, 2011 6:13 AM To: 'Access > Developers discussion and problem solving' Subject: Re: [AccessD] > Access 2007 - acCmdFind problem > > Hi Rocky > > This has nothing to do with solving your problem - sorry - but I just > had a question about part of your code ... > > Would this work the same? > > Private Sub NumLockChecker() > If Not (DLookup("NumLockPreference", "LocalOptions") = > IsNumLockOn) Then > ToggleNumLock End Sub > > Thanks > Bob Gajewski > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky > Smolin Sent: Monday, February 14, 2011 11:55 AM To: 'Access Developers > discussion and problem solving' Subject: Re: [AccessD] Access 2007 - > acCmdFind problem > > For #2 I use the following - except for the first module it's not my > code - I cribbed it from somewhere else. I store the user's > preference for num lock on or off in a local options table. > > > Private Sub NumLockChecker() > If DLookup("NumLockPreference", "LocalOptions") = True And > IsNumLockOn = > False Then ToggleNumLock > If DLookup("NumLockPreference", "LocalOptions") = False And > IsNumLockOn > = True Then ToggleNumLock End Sub > > Function IsNumLockOn() As Boolean > > Dim o As OSVERSIONINFO > > o.dwOSVersionInfoSize = Len(o) > GetVersionEx o > Dim keys(0 To 255) As Byte > GetKeyboardState keys(0) > IsNumLockOn = keys(VK_NUMLOCK) > > End Function > > Sub ToggleNumLock() > > Dim o As OSVERSIONINFO > > o.dwOSVersionInfoSize = Len(o) > GetVersionEx o > Dim keys(0 To 255) As Byte > GetKeyboardState keys(0) > > If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then > '=====Win95 > keys(VK_NUMLOCK) = Abs(Not keys(VK_NUMLOCK)) > SetKeyboardState keys(0) > ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then > '=====WinNT 'Simulate Key Press > keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, > 0 > 'Simulate Key Release > keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY _ > Or KEYEVENTF_KEYUP, 0 > End If > > End Sub > > Where the Type statement is > > ' Declare Type for API call: > Private Type OSVERSIONINFO > dwOSVersionInfoSize As Long > dwMajorVersion As Long > dwMinorVersion As Long > dwBuildNumber As Long > dwPlatformId As Long > szCSDVersion As String * 128 ' Maintenance string for PSS > usage > End Type > > And the constants: > > ' Constant declarations: > Const VK_NUMLOCK = &H90 > Const VK_SCROLL = &H91 > Const VK_CAPITAL = &H14 > Const KEYEVENTF_EXTENDEDKEY = &H1 > Const KEYEVENTF_KEYUP = &H2 > Const VER_PLATFORM_WIN32_NT = 2 > Const VER_PLATFORM_WIN32_WINDOWS = 1 > > I think that's everything. > > HTH > > Rocky Smolin > Beach Access Software > 858-259-4334 > Skype: rocky.smolin > www.e-z-mrp.com > www.bchacc.com > > > > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of jm.hwsn > Sent: Monday, February 14, 2011 8:19 AM To: 'Access Developers > discussion and problem solving' Subject: [AccessD] Access 2007 - > acCmdFind problem > > The project I am working on administers a questionnaire to students in > an attempt to bring down the attrition rate. > > The questionnaire is designed and administered by one or more > researchers. > > The questionnaire is not static. that is the researcher can add, > delete or modify the questions at any given time. > > This allows the researcher to place a question anywhere within the > questionnaire. > > There are 20 different types of questions, e.g. true/false, scale > (1-10 or 1-100), 4 point Lickert type, etc. > > The researcher can change the text of each response in a question as > well as change the text of the question. > > We are currently going through usability testing. The entire "class" > is around 500 students. The class has a 3 digit identifier that is > used in the questions. There are about 350 questions in the current > questionnaire. > > > > The researcher uses a Question form to modify the questions. The > question form has a sub form that shows an example of the question as > it would look on the questionnaire. When a search is done using a > list box for combo box the sub form changes to reflect the text and > type of question. When the question type changes the sub form updates > the sample. For example a question might change from a fill-in > question to combo box self-lookup question OR a question might change > from a 4 pt multiple choice to a 4 pt Lickert type question. > > > > Here are my questions: > > > > Question #1: > > As I mentioned above the class has a 3 digit identifier embedded in > some questions. The researcher puts this identifier within the > question to personalize it for the students. I have a button on the > question form that is used to search for questions with the 3 digit > class identifier. I use: DoCmd.RunCommand acCmdFind because, the 3 > digit class identifier will need to change periodically and this > allows the researcher to do a "replace all" after the search. > > > > I cannot figure out how to update the sample question sub form after > the "Find Next" button is clicked on the Find dialog box. > > Does anyone know how to run a custom function (update sub form) while > the dialog box is still open? > > > > Question #2: > > When the search button on the question form is clicked, I use SendKeys > to ensure that "Match" is set to "Any Part of Field" and that the > cursor goes to "Find What" field. That works, however, occasionally > the Num Lock key is turned off. I understand that I could use: > Application.SetOption "Default Find/Replace Behavior",1 - but that > would set it for all users. Is there some way to achieve the same > functionality without using SendKeys? > > > > Thanks in advance, > > Jim > > > > > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com >