Posts Tagged 'Modules'
Saturday, May 2nd, 2009 |
Sometimes it is necessary to prevent a form open if there are records to show, for example when doing a query and no registration is not required, we do not need to be open form since we have no data to display. So what we have to check is whether there are records to show and if there is no show a message and impede the form open. How?
It's easy to just put the code below in the form properties in the event 'to open':
= 0 Then If Form.RecordsetClone.RecordCount
MsgBox "No records found.", VbExclamation, "Error!"
DoCmd.Close acForm, "find data"
Exit Sub
End If
To see an example download: Prevent Form Open
Posted in Examples , Forms , Modules | 2 Comments »
Thursday, December 11th, 2008 |
1 - Create an order form in structure and event 'Clicking' on the properties of the form enter the following: me.keypreview = true
Or is this going to make the keyboard events are received in the first form.
2 - In the form properties, the event 'button below to' put the following code:
Private Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF2
DoCmd.OpenForm "Form1"
Case vbKeyF3
DoCmd.OpenForm "Form2"
Case vbKeyF4
DoCmd.OpenForm "formulario3"
Case vbKeyF5
As Double Dim Calculator
Calculator = Shell ("calc.exe", vbNormalFocus)
Case vbKeyF6
DoCmd.Close
Case Else
End Select
End Sub
What this does is the following:
- By pressing the F2 key opens the form1
- By pressing the F3 key opens Form2
- By pressing the F4 key opens the formulário3
- By pressing the F5 key opens the Windows Calculator
- By pressing the F6 key closes the form
In addition to the function key F1, F2 ... etc, we can also use any other button to perform functions, but keeping in mind that if we are to enter data in a form not suitable to use keys that are used to write data in the fields.
Another thing is that it only works on the form where you put the above codes.
Download: Keys

Posted in Examples , Forms , Modules | 1 Comment »
Saturday, September 20th, 2008 |
This is a kind of menu that allows us to save time, lines of code and a better arrangement in terms of open forms, since with this menu just need an open form. In addition to reducing the number of open forms also decreases the number of buttons in a menu to open each form.
This type of menu, certainly that has existed for some time and is already used by many users of Access.
So where is this menu?
Let's create the menu using a combo box that contains all the forms that we plan to open through it. When you select an option from the combo box the application form is displayed within the subform. Then we begin to make the menu step by step.
1 - Let's create a table where we will store the name you want to give each form and name of the form that will open. In the example I created the table 'tblmenu' with the following fields:
Field Type
Nomedomenu text -> Name that will be seen in the menu (combo box)
form text -> Name of the form that will open
After the data introduced in the example are:
NomedoMenu Form
Accounts Form1
Deposits Form2
Movements formulario3
Account-Box formulario4
Account-Account formulario5
Extract formulario6
2 - Then we create a query from the previous table:
Tblmenu chose the table and then choose the two fields in which we chose for ascending sort nomedomenu to be easier to find the menu quite a few times when we want to open forms. To this query I called 'CsMenu'.
3 - Let's create the form 'Menu', ie choose new form in Design view. Then we create a combo box and change the following properties:
- Number of columns: 2
- Column Widths: 1cm, 0cm;
- Origin of the line: csmenu (which is the name of the query created in the previous paragraph)
4 - In the same form we will create an unbound main form's subform (In the example I called menuquadro). It is this form that will be open each of the forms to choose from the menu (combo box).
5 - Now create a module that will allow us to open the menu that is selected in the combo box in the subform.
We created a module (which I called 'abrirmenu') and pasted the following code:
Public Function AtivarMenu (Combmenu The ComboBox, subabrir The Subform)
Abrirform As String Dim
= abrirform Combmenu.Column (1)
subabrir.SourceObject = abrirform
subabrir.LinkChildFields = ""
subabrir.LinkMasterFields = ""
End Function
After going to the properties of the combo box on the form menu and the After Update event put the created function: ativarmenu = ([Menu], [menuquadro]) that 'Menu' is the name of the combo box and 'menuquadro' the name of the subform.
And finally the menu is ready for use. Just try and use. I hope you enjoyed this tip.
Download: Menu
Below a picture of the menu.
Custom Menu
Posted in Examples , Forms , Modules | 12 Comments »
Tuesday, May 6th, 2008 |
This example shows how a management system for the provision of payments.
The example shows that this does is create and automatically with a click of a button, the benefits of a contract of sale through the data entered. That is, we introduce the client's name to the contract start date and the total amount payable. Then simply click the "calculate payments" that it automatically generates the number of installments and divides the value indicated by each of them and calculates the date of each installment (one per month). This is also an example that demonstrates how to add multiple records at once, because when you click the button it adds a record for each benefit.
Download: Insert Multiple Records
Posted in Dates , Samples , Forms , Modules , Records | 17 Comments »
Saturday, March 29th, 2008 |
This is an example of the application fields that Sónia reader intended for a database record data of animals. It is a simple database with just a form for data entry with a photo of the animal.
Download: Animal Shelter
Any change just comment here.
Written Forms , Photos , Modules , Records , Tables | 11 Comments »
Wednesday, February 20th, 2008 |
There are several ways to enter a record, and the most common is to get through a form bound to a table. Another way to do this is through unrelated fields, ie using a form with fields independent unrelated to the table. To
enter the data we use the 'recordset', ie by a code, which in the case of this example is as follows:
Dim db As Database
Dim rs As Recordset
If MsgBox ("Would you like to write?" VbYesNoCancel, "Options") = vbYes Then
"By pressing is asked whether to save the record or not, if so the code continues until end
Set db = CurrentDb ()
Set rs = db.OpenRecordset ("Data", dbOpenTable)
'Open the table to insert the data register
rs.AddNew
rs ("name") = Me! INome
rs ("address") = Me! Imorada
rs ("age") = Me! Iidade
rs.Update 'sends the data to the table
rs.Close 'Clear the data and closes the recordset
Set rs = Nothing
Set db = Nothing
Me.INome = Null 'clears the fields in the form
Me.Imorada = Null
Me.Iidade = Null
MsgBox "Record saved", vbInformation, "Done" 'Display confirmation message
Me.INome.SetFocus' Move the cursor to the first field
Else: Exit Sub
End If
Download: Place Independent
Posted in Examples , Forms , Modules , records , tables | No Comments »
Tuesday, February 19th, 2008 |
This example shows how to perform calculations on hours. It is useful for those who need to know how much time elapsed between a start time and end time. It is not enough to make the subtraction of the end time for the start time, because if the end time moving from one day to the next accounts will no longer correct, for example:
Start Time: 23:00:00
End Time: 02:00:00
End Time - Start Time = 02:00:00 to 23:00:00 = -21:00:00
Obviously it is not so simple to work with time, because then instead of having three hours to correct result would wrongly -21 hours.
To get around this period that goes from day to day we have to check first if the end time is greater than the start time, whichever is greater then the calculation is: End Time - Start Time.
If you are under then we have to do the calculation another way, namely:
Start Time: 23:00:00
End Time: 02:00:00
Total Time: 23:59:59
Hit: 00:00:01
Basically what we do is add to the value of 24:00:00 subtraction to give us the correct three hours. That is:
End Time - Start Time + Total Hours + Hit = 02:00:00 to 23:00:00 + 23:59:59 + 00:00:01 = 24:00:00 = 03 + -21:00:00 : 00:00
Download: Calculus with Time
Posted in Examples , Forms , Hours , Modules | 20 Comments »
Wednesday, February 6th, 2008 |
This example shows how to choose a date through a PopUp Calendar. That is, as a module and can form a select a date as this is a calendar. In the example we can choose the date by clicking the button next to the date field or clicking the right button of mouse in the date field. This way to enter dates is very practical since it allows us to see a calendar and to choose the best date you want.
Download: PopUp Calendar
Posted in Dates , Samples , Forms , Modules | 1 Comment »
Sunday, January 27th, 2008 |
Usually when we run the center button of a mouse on a form, change the access log. In some situations it may be useful that does not happen.
This example uses a module in the event of the form to load, to prevent the user navigate through the records using the scroll mouse. To test we can use the mouse wheel (middle button) to see that does not change the registration.
Download here: Wheel mouse
Posted in Examples , Forms , Modules , Mouse , Records | No Comments »
Monday, January 21st, 2008 |
This example uses a module that hides the Microsoft Access main window, leaving only the form's window visible.
To use this module we have to use the following command at the opening event of the form: call fsetAccessWindow (SW_HIDE).
To check by way of example do the downloa: Manipulate Window Acces
Posted in Examples , Forms , Modules | 8 Comments »