Sunday, August 14, 2011

How to add a search form on the Access database

!9# How to add a search form on the Access database

[if ]
[endif]

I use MS Access (Windows version in 2003) for the management of my list as my most important asset to my eBay store. I'm working primarily in one-of-a-kind merchandise that have, over time more than a thousand voices. That's a lot to keep track.

I needed to find a good way to find objects and in different sectors. You can use the "[control] + f" key combination, or you can use Edit | Find menu to search for, but access to fit the entire field by default and you must change ifYou want something different. Normally I do not think that all the field. I usually match a portion of the field.

Some people prefer to use keyboard shortcuts. Mice have more than one person, if they do one-click way to add a little '. If there is just one of clicking through the menus is that, even with only two clicks, such as Edit | Find, so I usually resort to press [Ctrl] + f. But this article is not whether a better method than the other, this article focuses on supplyto form a different way to search an Access database.

So, I have a small button that used to develop the system to find items in a particular area. I have the button on the right side of the field that deals with. Can I access the Find dialog box, the way I want it fixed with a single click.

I add the button to the form design using the tool button. If you select the Record menu | Find record action (a logical choice), then the assistant gives you the following code (we'll change the codebelow):

Screen.PreviousControl.SetFocus

DoCmd.DoMenuItem acFormBar, acEditMenu, 10, acMenuVer70

The first line is Screen.PreviousControl.SetFocus pleasant. It focuses on what field the last field that touches you're looking for. There is a button for all search operations in this way, but you must click on a box and then click the button. Here are two shots and not everyone can understand, this is the way it works.

The second line is DoMenuItemspecifications for each version of Access, and in this case means the tenth item on the Edit menu. You have to change this for each version of Access.

If you select the Record menu | Find Next question, the wizard gives you the following code:

Screen.PreviousControl.SetFocus

DoCmd.FindNext

The next place is better than DoMenuItem, because it is not necessary to modify the code for each version of Access. The dialog box that appears when you click the CustomThis article is a button on the Find Next button, so you do not really need two buttons, Find and Find Next. Search will do well for themselves.

Encoding Wizard Access is fine, but you have no control over the parameters for the search. I do not fit with the matchbox entire field of play on any part of the field, when I forgot and tried the whole area and can not find what I know must be there.

I need a way to look up each field with a single click, so I chose aButton to access it.

I have several fields where I want to be able to search for. I did not want to write the same code and always available for each field. If I were a better way to find it in the code, then I need to recode each instance, the old code. Once the procedure is much better.

My Button sets the focus of research in an area on the left side of the button, and then called a method of calling the find command. Each of these buttons on the form is the focus on the field to the leftand asks the same, a function to perform the search.

Before getting the code, I have the idea that questions where you put the method of coverage. If you have many keys, but only a form, then you can add the method in the code for the form itself. If you're more of a form, or if you make the process more generally, if you feel like it later in another form, then it is better to add this procedure to a form and not in modules. I call my formIn general, however, you can add one or more separate modules with associated procedures so you can easily import the new database you need. This could be your form FindRecord. You will find the modules in the main database tables, queries, forms, reports and macros.

If you put the procedures in the form code, then the scope of the procedure applies to the form. If you have your procedure in a form, and you must call on module 2, you receive an error message becauseModule 2 can not find it. In this case it could be another method to form and maintain two methods 2 or better to add, put the handler in a module, so that both forms can be found and you need to get a single procedure.

Once you have a general module, the code must also general references. You can not use the abbreviation Me is the name of a field, as you can in a procedure within a module. If a process is in a form that interprets the code to refer me to the form.

IfYou must reference the name of a field in a general module, you need a general statement such as:

Forms.frmInventory.PurchaseTotal

or

Forms! [FrmInventory]! [PurchaseTotal]

(You need to add parentheses when the name contains spaces)

PurchaseTotal here is the name of a form field in the collection frmInventory Forms Access database. If this frmInventory in the code, it would only be:

Me.PurchaseTotal

In our case we will use me in the OnClick propertyin the form in order to focus on a specific sector with the Me-established method and then call a method that is not necessary that the name of a field, thus circumventing the problem of me.

Here's how to create a convenient button to find:

* Make a button with the button tool and his assistant.
* Set the button to display the text and make this text to F.
* Name of the + button cmdFind field name, in order to find a field called cmdFindInvNum InvNum name.

After completing the wizard,Change the key:

* Set the font size to 6, a small size, but readable.
* Insert the tab NO because you do not have to stop when the button on the tab through the form.
* Set the status bar text and the text can ControlTip to register, so that users can easily remember which issues can be pushed the button when the mouse button.

Button sizes as small as possible and still be able to use D. 0.1708 inches wide by 0.166 inches high to seewith Arial text with my form grid. Its size may vary. This is a good size because its height is equal to the height of my text and combo boxes so that all fit togther in each row.

(After you have created a button in this way, you can copy and save the rest of the buttons with all these settings and in the copy. All you have to do is change the name of each button and add the OnClick Event Procedure below).

Now, set the OnClick propertyto [Event Procedure]. Before putting the case in order to act in a certain area. If the name of the field is the product number, then you write your routine event such as:

Me.ProductNumber.SetFocus

FindRecord

The first line sets the SetFocus action which field your procedure is suspect and Me.Productumber to name just a field. If you use Screen.PreviousControl.SetFocus because the wizard recommends, for the first row, then you will have everything in every field to the last searchtouched with the mouse. How nice, if that's what you want, but it's not what I want to do this button.

The second line, find the record, calling the custom procedure. (In Windows. After adding your custom job FindRecord, you can find the records coded to highlight the shape and the right mouse button and select the definition to go immediately to the code.)

Then add your own methods of a form and save:

Public Sub FindRecord ()

DoCmd.GoToRecord, acFirst

SendKeys"% N% Ha", False

DoCmd.RunCommand acCmdFind

End Sub

The first command is optional, so I can comment with an apostrophe before, if you do not want to use.

The first command sets the record pointer to the first record to start the search. I did it because I thought it best to start looking at first, but it is not necessary that this procedure works.

The second command sends the key code to set the Search dialog box. Here are someoptions from a Microsoft Knowledge Base http://support.microsoft.com/kb/120912 site: [out]

Select the box of matches:% h

Meeting Part of the field has%

Meeting Home field:% hs

Search only the current field (deleted):% s

If (selection>):% c

Search Fields as Formatted (selection):% or

Select the Find field: r%

Up Search: ru%

Search Down: rd%

Select the Find field:% s

For example, select SendKeys% h is the matchbox andSendKeys% have a game and check the box sets of the game to suit every part of the field. You do not have to do both, using a variant of the second statement. The same is true for r ° and SendKeys%% TO% or SendKeys SendKeys.

The particular combination in the procedure, as written here, the matchbox matches any part of the field, and then select the search box after the cursor focus. You are what you are trying to enter. Write your procedure with theDesired settings.

The second part of the SendKeys statement is a Boolean value that indicates the optional standby mode. If set to False (the default), the control of the process sent immediately after the keys are returned. If set to True, the process of keys before control is returned to the procedure. Technically, we do not need because we want to give wrong and that the default is False, but how do I get in, so it's clear to me in six monthsthat is what I wanted.

The % in front of each key value represents the Alt key in Windows, and I suppose it represents the Command key in Macs. In the code window, if you highlight SendKeys in the code and press the F1 function key; then a help screen will come up and explain general information about SendKeys. Don't look to Access help for the specific Find key codes shown above; Access help is general and not all inclusive.

The third command runs the Access Find action as set up by you. This is finally the command that does what you want.

I admit that this is a crude way to do things, but this is what Access gives us. The SendKeys way is better than the DoMenuItem way but it can have problems in a multi-user environment, as I have read but not experienced.

You can experiment with different combinations of key codes. You can send keystrokes on different lines or combine them into one line as I have done. I recommend placing them all in onelike as the example does. If you use the %n key code, then put it at the end because it sets the focus to the Find What box and it should come last.

Try this out on your Access forms and see if this is useful. I find it helpful because general users will not know to press [control] + f or to use the Edit | Find menu to find something. Both are too nerdy. If they do know about them, it is my experience that they will be tripped up occasionally by the default match whole field setting and not know how to get what they want. Much depends on the training and the frequency of use. People who are well educated are better than low achievers. People who can not remember are rarely as good as a regular user.

When users see a button next to the field, and F shows that when you find ways that they are using is probably why research is so important to use a database that they want to find an easy way.

I will show you how to add other useful buttons form in the forms of accessother articles.


How to add a search form on the Access database

Coupon Schwinn Free Wheeler Double


Twitter Facebook Flickr RSS



Français Deutsch Italiano Português
Español 日本語 한국의 中国简体。







Sponsor Links