<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener("load", function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <iframe src="http://www.blogger.com/navbar.g?targetBlogID=34083602&amp;blogName=LEARN+MS-ACCESS+TIPS+AND+TRICKS&amp;publishMode=PUBLISH_MODE_FTP&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;homepageUrl=http%3A%2F%2Fmsaccesstips.com%2F&amp;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" title="Blogger Navigation and Search"></iframe> <div></div>

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Saturday, November 29, 2008

Custom Calculator and Eval Function

When we think of a Calculator the image that comes into our mind is the traditional type with button labels 0-9 and with Arithmetic Operators. We have it in Windows Accessories Menu that can be converted into a Scientific Calculator as well. So we don't need to build that again in MS-Access.


We are considering another type of Calculator that can accept a User Defined Expression (consisting of Data Field Names, Constants, Arithmetic Operators, Parenthesis to alter the Order of Calculations), evaluate that expression and provide a quick result.


We don't need to embark on a fancy design task for this Calculator. All we need is a Text Box to enter the Expression, a Command Button and few lines of Code. The result of the calculation can be displayed either in MsgBox or in another Text Box.


Before we start working on the Calculator Project, let us take a look at one of the built-in functions EVAL(), which is the main work-horse of our Custom Calculator. With this Function we don't have to worry much about the calculation rules, like evaluate expressions in parenthesis first, exponentiation next, multiplication and division next (from left to right, if more than one operator), do addition and subtractions last etc. All you need to do is to give the Expression in String Form into EVAL() Function and get the result as output, as simple as that.


Want to try few examples quickly to get a feel of it? Open the VBA Module Window (Alt+F11) and open the Debug Window (Ctrl+G). Type the following expressions in Debug Window and press Enter Key:


? EVAL(“2+3*4/2”)

Result: 8

? EVAL(“(2+3)*4/2”)

Result: 10

? EVAL("log(SQR(625))/log(10)")

Result: 1.39794000867204

? Eval("10^" & "Eval('log(Sqr(625))/log(10)')")

Result: 25

? EVAL("Datediff('yyyy',Forms!Employees!BirthDate,date())")

Result: 45 (the Employees Form must be open)

What we can see from the above examples is that you can write an expression using built-in Functions, Data Field References and Numeric Constants in a Text Box on a Form and submit it to Eval() Function, it can give you the result of that Expression. It gives the User the ability to define an expression and do calculations with the use of Data Field values on the Form.


Tip: The Eval() Function can do lot more than simply evaluating the formula, it can run another Function, trigger the Click Event of a Command Button or Run a Macro. For more details and examples of Eval() Function search Microsoft Access Help in VBA Window.


I have created a sample Database (you can download it from the bottom of this Post) for an Auto Dealer who extends Credits to his Customers with a nominal charge of interest rate 6%, 7% or 8% repayable in 24, 36 or 60 installments slabs respectively. The Salesman has been instructed to deal with the Customers suitably to promote Vehicle Sales. The Salesman has to decide which slab of repayment is appropriate for a particular customer, percentage of down payment, repayment schedule with applicable interest rate. The Salesman is given the freedom of allowing a discount up to a maximum of 20% on Retail Price.


An image of the Form he uses to run these calculations is given below:

Custom Calculator Image
This is a stand alone Form (can be linked to Table) with Unbound Text Boxes. The Text Box names are given as Labels to the left. While writing the Expression it is a must to qualify the control Names correctly like Forms!CustomCalculator!Balance. It will not accept references like Me!Balance. It is difficult to use these lengthy names to build the expression when several Field names are involved in the Formula.


We have a small VBA routine to accept the Text Box Names in square brackets [ ], to pick their values and replace it in the expression before submitting it to EVAL() function.


A Combo Box with Arithmetic Operators and Text Box Names in square brackets is also provided on the Screen for easy entry of expressions. The colored control below displays (displayed by the routine for information only) the replaced value of Text Boxes in the expression before submitting it to the EVAL() Function.


When the Calculate Command Button is clicked the result of the calculation is displayed in the Text Box with dark background and the label Result. The VBA Code is given below:




Private Sub cmdCalc_Click()
'-----------------------------------------------------------
'Author : a.p.r. pillai
'Date : November, 2008
'URL : www.msaccesstips.com
'All Rights Reserved by www.msaccesstips.com
'-----------------------------------------------------------
Dim str As String, loc1 As Integer, chk As Integer
Dim strout As String, loc2 As Integer, loc3 As Integer
Dim strin As String
Const sqrleft As String = "["
Const sqrright As String = "] "

On Error GoTo cmdCalc_Click_Err

'change the reference if different
str = Me![Expression]

loc1 = InStr(1, str, sqrleft)
If loc1 > 0 Then
strin = Left(str, loc1 - 1)
strout = Left(str, loc1 - 1)
loc2 = InStr(loc1, str, sqrright)
End If
Do While loc2 > 0
strin = strin & Mid(str, loc1, (loc2 - loc1) + 1)
strout = strout & Me(Mid(str, loc1, (loc2 - loc1) + 1))
loc1 = InStr(loc2 + 1, str, sqrleft)
If loc1 > 0 Then
loc2 = InStr(loc1, str, sqrright)
If loc2 = 0 Then
MsgBox "Errors in Expression, correct and retry. "
Exit Sub
Else
strout = strout & Mid(str, Len(strin) + 1, loc1 - (Len(strin) + 1))
strin = strin & Mid(str, Len(strin) + 1, loc1 - (Len(strin) + 1))
End If
Else
loc3 = loc2
loc2 = 0
End If
Loop

If Len(str) > loc3 Then
strout = strout & Mid(str, loc3 + 1)
End If

'this line can be removed if not required
Me![parsed] = strout

'change the reference, if different
Me![result] = Eval(strout)

cmdCalc_Click_Exit:
Exit Sub

cmdCalc_Click_Err:
MsgBox Err.Description, , "cmdCalc_Click()"
Resume cmdCalc_Click_Exit

End Sub

Private Sub cmdReset_Click()
Me![Expression] = Null
Me![parsed] = Null
End Sub


There is no validation check included in the Code to detect misspelled names or unbalanced parenthesis etc. These short comings will automatically generate an error when the EVAL() function executes. The user will be able to review the expression, make corrections and re-try.


You can implement this program on any Form with small change in str = Me![Expression] and Me![result] = Eval(strout) lines in the Code, if different names are used. Customize the Combo Box contents based on your input Field Names.



Download - File: CustomCalc.zip (Size:21.8K)





StumbleUpon Toolbar




Lost Links of External Tables
Link External Tables with VBA
Source Connect Str Property and ODBC
Access Live Data in Excel-2
MS-Access Live Data in Excel

Labels:

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Friday, November 21, 2008

Data Editing And Security Issues

Data Entry and Editing is a major activity for maintaining the information up-to-date in databases, before we are able to prepare any meaningful output for human consumption. It is important that we make these tasks easier to the User by providing Combo Boxes, Check Boxes or Calculated Fields, like Payment-Due-Date after 30 days of Material-Delivery-Date and so on.


Another important aspect is data security. I am not referring to the protection against unauthorized access from outside, for which we have adequate built-in MS-Access Security features that can be put to use. Here, our emphasis is on unintentional changes or deletions of important information by Authorized Users.


For example, assume that our Employee database has a Memo Field that holds important detail information on educational and past experience of employees. Normally when the Cursor (Insertion Point) moves into a field the entire field contents will get highlighted and selected. At this point if the User's attention is drawn to something else and touches a key by mistake the field contents will be erased. If she is not aware of this or forgot to recall the lost data by pressing Ctrl+Z (Edit - -> Undo Typing) then it is lost for ever.







We will concentrate on this particular behavior of the Cursor and how we can give some form of protection against such inadvertent mishaps. The Cursor behavior, while entering into a field, is governed by the settings in the Keyboard Tab of Options… in Tools Menu. Find the three different options available under the Behavior entering field Options Group in the image below:

Behavior Entering Field Options


The first option Select entire field is the default setting. One of the other two settings is the most preferable one to avoid lose of information that we are focusing on. Out of the other two Options I prefer the last one, Go to end of field, why because even if you press the Delete Key or any other Key by mistake, while the insertion point is at the end of the field contents, nothing will happen to the existing information.


Since, this is the global setting of MS-Access Application, the changes that you make here manually affects all the Forms in all Databases that you load into your machine. Conversely, the database that you have designed on your machine will not carry this option setting along with it when open on some other machine in a multi-user environment. More over, we may not need this setting to take effect on all Forms in the Database either.


So the best approach is to enable this feature through VBA Sub-Routines, wherever we need it on Forms and turn it back to the default settings while the Form closes. If your database is shared on a Network the Behavior Entering Field default settings can be different in other machines set by the User. We don't want to alter this settings permanently.


Following are the numeric value of each Behavior Entering Field Option setting:

Behavior Descritpion Option Values

  1. Select Entire Field - 0

  2. Go to Start of Field - 1

  3. Go to End of Field - 2



When we open a Form, where we need this change of behavior, we will go through the following steps to enable it and when the Form is closed put the default setting back in its place:

  1. Save the current default setting of Behavior Entering Field, before changing it.

  2. Change the setting to Go to end of Field behavior for the current session of the Form.

  3. Reset it back to the saved value in Step-1 above before closing the Form.


We can achieve this with the following Event Procedures in the Form Module:

Option Compare Database

Dim DefaultBehavior As Integer

Private Sub Form_Load()

DefaultBehavior = Application.GetOption("Behavior Entering Field")
Application.SetOption "Behavior Entering Field", 2

End Sub

Private Sub Form_Unload(Cancel As Integer)
Application.SetOption "Behavior Entering Field", DefaultBehavior
End Sub


Copy and paste the above Code into the Form's Code Module and save the Form. The Dim DefaultBehavior As Integer statement must be placed at the Global area of the Module as shown above.


Open the Form in normal View and try moving the Cursor from one field to the other by tapping Tab Key or Enter Key. The insertion point will position at the end of the field contents.



StumbleUpon Toolbar



Link External Tables with VBA
Source Connect Str Property and ODBC
Access Live Data in Excel-2
MS-Access Live Data in Excel
Database Connection String Properties
Opening Excel Database Directly

Labels:

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Saturday, November 15, 2008

Event Trapping Summary On Datasheet

How do we use Event Procedures like LostFocus(), GotFocus() on Datasheet view?


How to display Summation of numeric values on Datasheet view?


For answering both questions, we need a sample Table and a Datasheet Form.


Import the following Tables from the Northwind.mdb sample database from C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb.


  • Order_Details

  • Products



We require the Products table also, because it has a reference in the ProductID field of Order_Detail Table in a Combo Box. We don't want to leave the ProductID field empty on the Order_Detail Table, without the Products Table.


  1. To Create a Datasheet Form, click on the Order_Detail Table, select Form from Insert Menu and select Autoform: Datasheet from the displayed list of options in the Formwizard.


  2. A Datasheet form will be created and will open the Table contents in Datasheet View.

  3. Select Save As… from File Menu and give the name Order Details for the Form. The Datasheet Form will be saved, but it will not be closed.

  4. Select Design View from View Menu to change the Form in Design View mode.


The Form in Design View looks like the image given below or may be different depending on your version of MS-Access.

Datasheet Form in Design View
Doesn't matter how the Fields are arranged on the Form, whether in row format or Column Format the data will be always displayed in Datasheet format. The placement of Fields will not affect the way the data displayed on the Datasheet but the Tab Order does.


Let us try and find out how the Tab Order of Fields influences the Datasheet View.


  1. Change the Form into Datasheet View (View - - > Datasheet View) and check the order of fields appearing in there.

  2. Change the View into Design mode again and re-arrange the ProductID and UnitPrice fields by switching their places.

  3. Change the View back to Datasheet and inspect the data field order.


  4. There will not be any change in the Order of Fields displayed from previous View. If you move the Cursor using Tab Key then it moves in the same order of the fields' placement as you have seen earlier before switching the fields.


  5. Change the Form back to Design View again.

  6. Select Tab Order… from View menu. Click at the left border of the UnitPrice field on the Tab Order Control, click and drag it up and place below the OrderID field.


  7. Tip: You can click on the Auto Order Command Button to re-arrange the Tab Order according to the field placements on the Form.


  8. Open the Form in normal view now and check the change of field placements.


We will add one Unbound Text Box on the Form to calculate the Extended Price after adjusting Discounts of each item.


  1. Open the Form in design view, if you have closed it.

  2. Drag the Form Footer Section down to get more room to place another Text Box below, or you can place it to the right of the Discount Field too.


  3. Create a Text Box and write the formula =(1-[Discount])*[UnitPrice]*[Quantity] in it.


  4. While the Text Box is still in selected state display the Property Sheet (View - -> Properties).


  5. Change the Format Property value to Currency format. Change the Name Property value to Extended Price.


  6. Open the Form in normal view and check the newly added Text control's heading on the top. It will be something like Text10:.


  7. In Datasheet View of Forms MS-Access uses the Caption of the Child Labels attached to the Text Boxes as Field headings. We have changed the Name Property of the Text Box to Extended Price, but that is ignored here.


  8. Now, change the Form into design view and delete the Child Label attached to the Extended Price Text Box.

  9. Change to Datasheet view again and check the field name appearing on the top, it will be Extended Price now.



Datasheet Event Procedure

  1. To try an Event Procedure on the Datasheet view, copy and paste the following VBA Code into the Form's Code Module (View - -> Code to display the Code Module of the Form) and save the Form with the Code.


  2. Private Sub UnitPrice_LostFocus()
    Dim newUnitPrice As Double, msg As String
    Dim button As Integer

    button = vbQuestion + vbYesNo + vbDefaultButton2

    If Me![UnitPrice] <> Me![UnitPrice].OldValue Then
    msg = "Replace UnitPrice: " & Me![UnitPrice].OldValue & vbCr & vbCr
    msg = msg & "with New Value: " & Me![UnitPrice]

    If MsgBox(msg, button, "UnitPrice_LostFocus()") = vbNo Then
    Me![UnitPrice] = Me![UnitPrice].OldValue
    End If
    End If

    End Sub


    We will attempt to trap the change in the UnitPrice field and will ask the User to confirm whether to retain the change or Cancel it.


  3. Open the Form in datasheet view and make some change in the UnitPrice Field and leave the Field by pressing Tab Key or Enter key.


A Message Box will appear asking for permission to retain the change or to cancel it.


Datasheets can be programmed with Event Procedures (Field level or Form level) for validation checks and display of information.


Display of Summary Information

Method-1

We will attempt to answer the second Question we have raised on top of this page.


  1. Open the Order_Details Form in Design View.

  2. Drag the Form Footer Section down to get enough room to place two Text Boxes. Create two Text Boxes in the Form Footer Section.

  3. Write the formula =Sum([Quantity]) in the first Text Box.

  4. Display the Property Sheet of the Text Box and change the Name Property value to TOTALQTY.

  5. Write the formula =Sum((1-[Discount])*[UnitPrice]*[Quantity]) in the second Text Box.

  6. Change the Name Property Value to TOTALVALUE.


When we open the Order_Details Form in Datasheet View it will calculate the Summary Values in TOTALQTY and TOTALVALUE Text Boxes on the Footer of the Form, but we must do something to display it.


The first thought that comes into one's mind is to create a MsgBox and display the results in it on some Event Procedure of the Form. Besides, changes may takes place on the records and they should reflect in the result summary values and we must be able to refresh the change before displaying it again.


We will implement this method before we settle down with a better one.


  1. Copy and paste the following Code into the Form's Code Module and save the Form:


  2. Private Sub Form_DblClick(Cancel As Integer)
    Dim msg As String
    Me.Refresh
    msg = "Total Quantity = " & Me![TOTALQTY] & vbCr & vbCr
    msg = msg & " | Total Value = " & Format(Me![TOTALVALUE], "Currency")

    MsgBox msg
    End Sub


  3. Open the Form in Datasheet View.

  4. Double-Click on the Record Selector at the left border of the Form.


  5. A Message Box pops up with the Summary Values from the Text Boxes in the Form Footer Section.


  6. Make some changes on the Quantity/UnitPrice Fields and try Step-3 again. The change of Value will reflect on the Message Box.

  7. You can filter the Data on ProductID or on OrderID by Right-Clicking on these fields and selecting Filter by Selection or other Options available on the displayed Shortcut Menu and by executing Step-3 to get the Summary of selected records.



Method-2

After trying out the above method your response may be something like "Yah.. it serves the purpose, but it doesn't give the impression of a sophisticated method. After all it takes so many clicks and pop-up Message Boxes". I agree with you too.


With a small change of the above Code we can make the results the way you like it, I hope!.


  1. Open the Form in Design View.

  2. Display the Property Sheet (View - - > Properties).

  3. Select the Mouse Move Property and select Event Procedure from the drop down control.

  4. Click on the build () button at the right side of the Property to open the Form's Code Module.

  5. Cut the Code lines from within the Form_DblClick() Event Procedure:



  6. Private Sub Form_DblClick(Cancel As Integer)

    End Sub


    Leave the above lines alone and paste the Code into the Form_MouseMove() Event Procedure.


  7. Change the line that reads:


  8. MsgBox msg

    to

    Me.Caption = msg

    After the change the Code will look like the following:



    Private Sub Form_DblClick(Cancel As Integer)

    End Sub


    Private Sub Form_MouseMove(button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim msg As String
    Me.Refresh
    msg = "Total Quantity = " & Me![TOTALQTY] & vbCr & vbCr
    msg = msg & " | Total Value = " & Format(Me![TOTALVALUE], "Currency")
    Me.Caption = msg
    End Sub


  9. Open the Form in Datasheet View and move the Mouse over into the data area by crossing the Field Headings or the Record Selectors at the left side.

  10. Check the Title Area of the Datasheet View and you will find the Summary information is displayed there. A sample image is given below:


Summary Info in Datasheet Title Area

Now you can try changing the field values or filtering the data and moving the Mouse over the Field Headings or Record Selectors at the left to get the result on the Title Bar instantly. No Message Boxes or Double-Clicks and what you say about that?


StumbleUpon Toolbar



Source Connect Str Property and ODBC
Access Live Data in Excel-2
MS-Access Live Data in Excel
Database Connection String Properties
Opening Excel Database Directly

Labels:

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Thursday, May 29, 2008

List Box and Date Part Two

Continued from LIST BOX AND DATE PART ONE

We have seen that when working with date values in List Boxes we have to convert the selected value into one form or the other before they can be used for data processing tasks. We will try two more examples here with different date expressions. In all these cases the output is same but data selection parameters are used differently.


We can Filter Data using Data Range parameters i.e. by entering Start-Date in a Text Box and End-Date in another, on a Report Parameter Screen, or by entering these values directly into Parameter Queries to filter data from the Source Table or Other Queries. But here we are trying to do it differently and get some familiarity in working with Date related expressions.


  1. Open the Form LISTBOXDATE that we have created in the earlier example in Design View.

  2. Make a copy of the List Box and Paste it in the same area of the Form. Drag and place it to the right side of the Combo Box. See the Sample image given below:


  3. List Box  in design view

  4. Place the child Label on the top and display its Property Sheet (View - -> Properties). Change its Caption Property to List (Type-2).


  5. Click on the List Box and display the Property Sheet (if you have closed it) and change the following Properties:



  6. · Name = List2
    · Row Source Type = Value List
    · Row Source = 01;"Jan";02;"Feb";03;"Mar";04;"Apr";05;"May";06;"Jun";07;"Jul";08;"Aug";09;"Sep";10;"Oct";11;"Nov";12;"Dec"
    · Column Count = 2
    · Column Heads = No
    · Column Width = 0";1.5"
    · Bound Column = 1
    · Default Value = 1
    · Multi Select = None


    At this stage your attention is drawn on few property settings on this List Box. Check the Row Source Property setting. Here the List Box item values are inserted in pairs like 01;"Jan" for January and others. The Column Count property says there are 2 columns in this List Box. When the contents of the List Box is displayed these values should appear in two columns, value 01 in first column and Jan in second. But here the value Jan from 2nd column only shows up.


    The first column value is kept hidden with the Column Width Property settings 0";1.5". The first column width 0" prevents the value from showing up in the List Box. The Bound Column = 1 property setting takes the selected value from the first column, even if it is kept hidden. The Default Value = 1 says take Jan as default value, if nothing is selected by the User.


  7. Create two Text Boxes to the left of the List Box and below the other Text Boxes. Change the Caption of the child Labels to Method-2 and Method-3.

  8. Change the Property Values of the first Text Box that you have drawn now to the following Values:


  9. · Name = Method2
    · Control Source = =Format(DateSerial([cboyear],[List2],1),"mmm-yyyy")

  10. Change the Property Values of the second Text Box to the following Values:


  11. · Name = Method3
    · Control Source = =[cboYear]*100+[List2]

  12. Create a Command Button to the right of the existing two buttons and change the Property Values as shown below:


  13. · Name = cmdDisplay2
    · Caption = Display-2

  14. Create another Command Button and place it to the right and change the Property Values as given below:


  15. · Name = cmdDisplay3
    · Caption = Display-3


  16. Display the VBA Code Module of the Form (View - - > Code), add the following VBA Code into the Module by copying and pasting it below the existing Code:


  17. Private Sub cmdDisplay2_Click()
    Me.Refresh
    DoCmd.OpenQuery "Display2_listbox", acViewNormal
    End Sub

    Private Sub cmdDispaly3_Click()
    Me.Refresh
    DoCmd.OpenQuery "Display3_listbox", acViewNormal
    End Sub


  18. Open a New Query in Design View without selecting any file from the displayed list. Open the SQL editing Window (View - -> SQL View), copy and paste the following SQL String and save the Query with the name DISPLAY2_LISTBOX:


    SELECT Orders.*
    FROM Orders
    WHERE (((Format([orderdate],"mmm-yyyy"))=[Forms]![LISTBOXDATE]![Method2]));


  19. Open another New Query in Design View, Copy and Paste the following SQL String into the SQL editing Window and save it with the name DISPLAY3_LISTBOX:



  20. SELECT Orders.*
    FROM Orders
    WHERE (((Format([orderdate],"yyyymm"))=[Forms]![LISTBOXDATE]![Method3]));


  21. Open the LISTBOXDATE Form in normal view and click on the Command Button Display-2. The Query DISPLAY2_LISTBOX will open up with filtered output data using the current value in the Text Box with the name Method2. Select different Values in the Year Combo Box and the new List Box and try it again. Check the accuracy of the data filtered.


  22. List Box-2 in design view

    NB: If the Query displays some error then try to link the essential Library Files to your Project. Visit the Page Command Button Animation for details of Library Files and follow the procedures explained there. The Orders Table doesn’t have all twelve months data except for the Year 1997. Check for the Range of months available in 1996 and 1998 year’s data in this Table and select a month for available data for testing.


    Every time you select different Values in the List Box and the Combo Box, the value in the Text Box with the name Method2 and Method3 also changes. Close the Datasheet View of the Query before clicking the Command Button with a different selection of values.


  23. Click on the Command Button Display-3 to open the Query DISPLAY3_LISTBOX with the filtered output using the Text Box named Method3 Value.


NB: You must change the Visible Property of these Text Boxes to No to keep them hidden from your Application Users. Study the expressions written in the Text Boxes and their corresponding Formula written in the Query Column to compare both values.


We have used the Multi Select Property of the List Boxes in the first two Articles Selected List Box Items and Dynamic Query and Create List from Another List Box With Simple and Extended value settings respectively but here we have turned it off.


When you open the Form with the List Boxes with these settings (Extended or Simple) for the first time, the Text Boxes with the expressions using values from the List Boxes will be loaded with the values calculated from the default values, if Default Value Property is set with some value. But when you click on an item in the List Box the Text Boxes will show either #Error or will be Empty.


When the Multi Select Property is set with the Simple Value you can click on List items one by one to select one or more items or to deselect them, when clicked on it again. When the Extended value is set you can select a series of items, adjacent to each other, by clicking the first and last item by holding the SHIFT Key. Or click and drag the Mouse over the list items without the use of SHIFT Key. You must hold CTRL Key and click on items one by one for random selections as we did with Simple value setting.


We have used the Multi Select Property value equal to None (default setting) because our examples presented here works on a single item from the List Box.




Double Action Command Button
Sending Alerts to Workstations
Refresh Dependant Combo Box Contents
Filtering Data for Different Users
Crosstab Union Queries for Charts

Labels:

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Thursday, May 22, 2008

List Box and Date Part One

One of our regular readers from South Africa, Mr. Nick Els, has made a suggestion to bring out an Article on usages of List Boxes with Date related settings. This is the First Part of a two part Series on this particular Topic. You may go through the earlier Posts: Selected List Box Items and Dynamic Query and Create List from Another List Box.


Descriptive names of Months or its Numeral form combined with Year Values from Combo Boxes or List Boxes can be used in a variety of ways for comparing with Date Field values in Queries for filtering data. I mentioned variety because all methods require creating expressions at Query level or in Text Boxes on Forms to reformat the values into a compatible form before they are being compared. We will split this Article into two parts instead of overcrowding with all of them here.


List Boxes can be created on Data Entry Forms, Main Switchboards (Control Screen) for opening Forms or Reports or on Report Parameter Forms for using in Queries for Data Processing tasks and so on. One or more Values from List Boxes can be selected and used directly in queries or VBA Routines to filter data from underlying tables, as we did in the earlier examples with List Boxes.


A reference to the selected List Box item can be set directly in a Query Criteria Row or extract the selected value into a Text box with the help of a formula (like =[List1] in the Control Source property) and reference it in Query to Filter Values from the underlying Table.


There are few things that we should know about the Multi Select Property settings of List Boxes, advantages or disadvantages and how they influence the expressions, which we build using the selected item in Text Boxes or in referencing directly on Query Criteria. These can be looked into in the second part of this Article instead of getting too deep into them at this stage and get confused.


  1. Download the following four Tables from the Northwind.mdb sample database. We will be using only the Orders table now. There are references to the other Tables from Orders table and this may cause errors while opening the Query created on Orders Table without the other tables in your Project. If you are not sure about the Location of the NorthWind.mdb sample Database, visit the Page Saving Data on Forms not in Table for its location references.


    If you prefer to use a Table from your own Project you may do so, but you have to edit the expressions to change the Table Name and Field Names presented here before they are used with your Table.


    · Orders
    · Customers
    · Employees
    · Shippers

  2. Copy and paste the following SQL string into the SQL Editing window of a new Query and save the Query with the name OrderYearQ.


  3. SELECT Year([OrderDate]) AS OrderYr
    FROM Orders
    GROUP BY Year([OrderDate]);


  4. Open a New Form in Design View. If the Toolbox is not visible then select Toolbox from View Menu.


  5. De-select the Control Wizard (top right-side control on the Toolbox) if it is in selected state. Select the List Box Tool and draw a List Box as shown on the design below.


  6. List Box  in design view

  7. Click on the Child Label attached to the List Box and display the Property Sheet (View - - > Properties) change the Caption Property to List1 (Type-1) and position the Label above the List Box.


  8. Select the List Box, display the Property Sheet (if you have already closed it) and change the following property values as indicated against each one:


  9. · Name = List1
    · Row Source Type = Value List
    · Row Source = "January";"February";"March";"Apri";"May";"June";"July";"August";"September";"October";"November";"December"
    · Column Count = 1
    · Column Widths = 1.5"
    · Bound Column = 1
    · Default Value = "January"
    · Multi Select = None


  10. Turn on the Control Wizard we have disabled in Step 5. Select the Combo box Tool and draw a Combo Box at the top and to the right of the List Box. Select the OrderYearQ Query, that we have created in Step-1, from the Queries List.


  11. Change the following Property Values of the Child Label and the Combo Box.


  12. Child Label:
    · Caption = Year
    Combo Box:
    · Name = cboYear
    · Column Count = 1
    · Column Heads = No
    · Column Widths = 0.5"
    · Bound Column = 1
    · List widths = 0.5"
    · Default Value = =DMin("orderyr","orderyearQ")+1


  13. Create a Text Box below the Combo Box and change its Child Label Caption to Method-1. Select the Text Box and change the following Properties:


  14. · Name = Method1
    · Control Source = =Format(DateValue("01" & "-" & [List1] & "-" & [cboyear]),"yyyymm")

    The Visible Property of this Control can be set to No to hide it from Users, if needed.


  15. Create two Command Buttons below the List Box.


  16. Change the first Command Button’s Name Property to cmdDisplay0 and change the Caption Property to Display-0.


  17. Create a second Command Button to the right of the earlier one and change the Name Property to cmdDisplay1 and the Caption Property to Display-1.


  18. Display the VBA Module of the Form (View - - > Code), copy and paste the following VBA Code into the Module and save the Form with the name LISTBOXDATE.



  19. Private Sub cmdDisplay0_Click()
    Me.Refresh
    DoCmd.OpenQuery "Display0_listbox", acViewNormal
    End Sub

    Private Sub cmdDisplay1_Click()
    Me.Refresh
    DoCmd.OpenQuery "Display1_listbox", acViewNormal
    End Sub


    Note: You must save the Form with the above name for our examples. We will be setting references to the List Box, Combo Box and Text Box on this Form to use their current values in Query Criteria Rows.


  20. Open a new Query in Design View without selecting any of the Files displayed. Display the SQL Window (View - -> SQL View), copy and paste the SQL string given below and save it with the name DISPLAY0_LISTBOX.



  21. SELECT Orders.*, Format([orderdate],"mmmm") AS MTH, Year([ORDERDATE]) AS XYEAR
    FROM Orders
    WHERE (((Format([orderdate],"mmmm"))=[Forms]![LISTBOXDATE]![List1]) AND ((Year([ORDERDATE]))=[Forms]![LISTBOXDATE]![cboYear]));


  22. Create another Query with the following SQL string and save it with the name DISPLAY1_LISTBOX.



  23. SELECT Orders.*
    FROM Orders
    WHERE (((Format([OrderDate],"yyyymm"))=[Forms]![LISTBOXDATE]![Method1]));


  24. Open the Form LISTBOXDATE in normal View.


  25. List Box Preview

  26. By default January month is selected in the List Box and Year 1997 is set in the Year Combo Box as default value.


  27. The Text Box below the Combo Box displays the result of the formula that we have written using the List Box’s current selection of month and the Combo box value combined.


    The two Queries, which we have created, uses different methods to reference the contents of the List Box and the Combo Box.


  28. Select a month from the List Box. Select a different Year in the Combo Box, if needed (but be careful with the month selection because all twelve months data are not available except for the year 1997 in Orders Table).


  29. Click on the Command Button with the Caption Display-0. The DISPLAY0_LISTBOX Query will open in Datasheet view with the data corresponding to the Month and Year settings in the List box and the Combo box respectively. Close the Datasheet View of the Query before trying it out with the different settings.


    NB: If the Query displays some error then try to link the essential Library Files to your Project. Visit the Page Command Button Animation for details of Library Files and follow procedures explained there.


  30. Open the first Query DISPLAY0_LISTBOX in design view and check the criteria settings that we have created to compare the Order Date with the settings on the Form.


  31. We have created two columns with expressions for converting the Order Date Value into the descriptive name of the Month in the first column and to extract the Year Value in the second Column. On the criteria row we have set a direct reference to the selected month in the List Box and the second column criteria is set with a reference to the current Value of the Combo Box.


  32. Click the Command Button with the Caption Display-1.



It will open the second Query DISPLAY1_LISTBOX with the same result. But this query has only one column with an expression to compare the value with the Text Box contents on the Form. The Text box has the formula =Format(DateValue("01" & "-" & [List1] & "-" & [cboyear]),"yyyymm") to combine both Month and Year values, from List Box and Combo box respectively, together and referenced from the Query criteria row.


Study the expressions written on the Queries and on the Form controls and try to understand how they work. You may create Text Boxes and Queries of your own using the same List Box and Combo Box values and try them out differently, which will give you more insight into these methods.




Sending Alerts to Workstations
Refresh Dependant Combo Box Contents
Filtering Data for Different Users
Crosstab Union Queries for Charts
Union Query

Labels:

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Thursday, May 15, 2008

Create List from another Listbox.



If you have not tried the earlier example Selected List Box Items and Dynamic Query please visit that page and try it out before continuing with this. The Table and Queries created for that example are used here also.


I will give you briefly what you should do before continuing. Import the Orders Table from the Northwind.mdb sample database. Create two Select Queries by copying and pasting the following SQL String into the SQL editing window and save the Queries with the names as suggested below.


  1. Query : OrdersinQ



  2. SELECT Orders.*
    FROM Orders
    WHERE ((([Orders].[OrderDate]) Between #5/1/1998# And #5/31/1998#));


  3. Query : OrdersOUTQ



SELECT OrdersINQ.*
FROM OrdersINQ
WHERE (((OrdersINQ.OrderID) In (11067)));


In the earlier example we have used a method by highlighting items and using them as criterion for the output Query. Here, we are using different methods for the same result in a variety of ways.


When you create a Form with Microsoft Access Form Wizard it will give you a list of Fields from the Source Table or Query in one control and will ask you to select the required fields for the Form. You are allowed to select the fields and put them into another List Box for creating the Form with the selected list. You are allowed to Add or Remove Fields from the List Boxes before moving into the Next step. We are going to create something similar to that.


To try this method we need two List Boxes. When the Form is open the first List Box will be populated with Order Numbers and Customer Codes from the Source Query OrdersinQ, that we have used in the earlier example Selected List Box Items and Dynamic Query. The User will select one or more items from the first List Box and click a Command Button with the right arrow > indicator to move the selected items to the right side List Box and remove them from the first one. A finished sample image in running view is given below.


Double List Box Image

If the user changes her mind and wants to remove one or more items from the Second List she can do so by highlighting them and clicking the second Command Button (with the left arrow < indicator). The selected items will be moved back into the original list and removes them from the second List Box. The user can repeat this selection process any number of times till she is satisfied with the final list and ready to click the Preview Orders Button to open either the Output Query OrdersOutQ itself or a Report or Form designed using it.


The selected items' Order Numbers will be extracted from the list and used for redefining the Select Query OrdersoutQ, as we did in the previous example.


Since, the method is different from what we have tried earlier, it takes one more list box and 3 more Event Procedures to implement it.


We use the Form_Load() event procedure to populate the first list box items rather than setting the Row Source property with the Columns of OrdersinQ Query manually. The user is given the freedom to move the items from one list to the other at will and the moved items are removed from the source list. To do this kind of tricks we cannot directly use the OrdersinQ Query as Row Source for the List Box, as we did in the earlier example.


We can easily implement another trick with only one line change in each of the Click Event Procedures of the Command Buttons and can remove both the Command Buttons altogether. Change the Header line Private Sub cmdin_Click() to Private Sub List1_Click() of the first command button. Similarly change Private Sub cmdout_Click() to Private Sub List2_Click() of the second Command Button and you can eliminate both the Command Buttons.


With this method multiple item selection is not possible because when you click on an item it will move out into the other list immediately.


You have now three different methods for List Boxes that you can use suitably in your Projects as the situation demands and show off your skill in variety of methods.


  1. Open a New Form in Design View.

  2. Disable the Control Wizard on the Toolbox and create a List Box on the Form. Change the Label Caption to Orders.


  3. Click on the List Box and display the Property Sheet (View - - > Properties) and change the following Properties:


  4. · Name = List1
    · Row Source Type = Value List
    · Column Count = 2
    · Bound Column = 1
    · Column Width = .5”;1”
    · Multi Select = Simple

  5. Select the List Box, copy and paste it to the right side, giving enough space between them to create Command Buttons (as shown in the design above) and change the Name Property of the new List Box to List2. Check and confirm that the other properties are matching with the above values. Change the child Label’s Caption as Selected Orders.


  6. Create two small Command Buttons in between the List Boxes. Change the Name Property of the top one to cmdin and put a greater than symbol (>) in the Caption Property.


  7. Change the Name Property of the second Command Button to cmdout and insert a less than symbol (<) in the Caption property.


  8. Create another Command Button below both List Boxes. Change the Name Property to cmdPreview and change the Caption Property to Preview Orders.


  9. Select File - -> Save and save the Form with the name ORDERLIST.


  10. Display the VBA Code Module of the Form (View - -> Code). Copy and paste the following Codes into the VBA Module of the Form.



  11. Private Sub Form_Load()
    '------------------------------------------------------
    'Author: a.p.r. pillai
    'Date : 10/05/2008
    'URL : http://www.msaccesstips.com
    'All Rights Reserved by msaccesstips.com
    '------------------------------------------------------
    Dim db As Database, rst As Recordset
    Dim xinlist As ListBox, strlist As String

    Set db = CurrentDb
    Set rst = db.OpenRecordset("OrdersinQ", dbOpenDynaset)
    Set xinlist = Me.List1
    strlist = ""

    Do While Not rst.EOF
    If Len(strlist) = 0 Then
    strlist = rst![OrderID]
    strlist = strlist & ";" & Chr$(34) & rst![CustomerID] & Chr$(34)
    Else
    strlist = strlist & ";" & rst![OrderID]
    strlist = strlist & ";" & Chr$(34) & rst![CustomerID] & Chr$(34)
    End If
    rst.MoveNext
    Loop
    rst.Close

    xinlist.RowSource = strlist
    xinlist.Requery
    End Sub




    Private Sub cmdin_Click()
    'Private Sub List1_Click()
    '------------------------------------------------------
    'Author: a.p.r. pillai
    'Date : 10/05/2008
    'URL : http://www.msaccesstips.com
    'All Rights Reserved by msaccesstips.com
    '------------------------------------------------------
    Dim xinlist As ListBox, xoutlist As ListBox, strRSource As String
    Dim listcount As Long, j As Long, strRS2 As String

    Set xinlist = Me.List1
    Set xoutlist = Me.List2

    listcount = xinlist.listcount - 1
    strRSource = xoutlist.RowSource
    strRS2 = ""

    For j = 0 To listcount
    If xinlist.Selected(j) = True Then
    If Len(strRSource) = 0 Then
    strRSource = xinlist.Column(0, j)
    strRSource = strRSource & "; " & Chr$(34) & xinlist.Column(1, j) & Chr$(34)
    Else
    strRSource = strRSource & ";" & xinlist.Column(0, j)
    strRSource = strRSource & ";" & Chr$(34) & xinlist.Column(1, j) & Chr$(34)
    End If
    Else
    If Len(strRS2) = 0 Then
    strRS2 = xinlist.Column(0, j)
    strRS2 = strRS2 & ";" & Chr$(34) & xinlist.Column(1, j) & Chr$(34)
    Else
    strRS2 = strRS2 & ";" & xinlist.Column(0, j)
    strRS2 = strRS2 & "; " & Chr$(34) & xinlist.Column(1, j) & Chr$(34)
    End If
    End If
    Next
    xoutlist.RowSource = strRSource
    xinlist.RowSource = strRS2
    xoutlist.Requery
    xinlist.Requery
    End Sub




    Private Sub cmdout_Click()
    'Private Sub List2_Click()
    '------------------------------------------------------
    'Author: a.p.r. pillai
    'Date : 10/05/2008
    'URL : http://www.msaccesstips.com
    'All Rights Reserved by msaccesstips.com
    '------------------------------------------------------
    Dim xinlist As ListBox, xoutlist As ListBox, strRSource As String
    Dim listcount As Long, j As Long, strRS2 As String
    Set xinlist = Me.List1
    Set xoutlist = Me.List2

    listcount = xoutlist.listcount - 1

    strRSource = xinlist.RowSource: strRS2 = ""
    For j = 0 To listcount
    If xoutlist.Selected(j) = True Then
    If Len(strRSource) = 0 Then
    strRSource = xoutlist.Column(0, j)
    strRSource = strRSource & ";" & Chr$(34) & xoutlist.Column(1, j) & Chr$(34)
    Else
    strRSource = strRSource & "; " & xoutlist.Column(0, j)
    strRSource = strRSource & ";" & Chr$(34) & xoutlist.Column(1, j) & Chr$(34)
    End If
    Else
    If Len(strRS2) = 0 Then
    strRS2 = xoutlist.Column(0, j)
    strRS2 = strRS2 & ";" & Chr$(34) & xoutlist.Column(1, j) & Chr$(34)
    Else
    strRS2 = strRS2 & ";" & xoutlist.Column(0, j)
    strRS2 = strRS2 & ";" & Chr$(34) & xoutlist.Column(1, j) & Chr$(34)
    End If
    End If
    Next
    xinlist.RowSource = strRSource
    xoutlist.RowSource = strRS2
    xoutlist.Requery
    xinlist.Requery
    End Sub




    Private Sub cmdPreview_Click()
    '------------------------------------------------------
    'Author: a.p.r. pillai
    'Date : 10/05/2008
    'URL : http://www.msaccesstips.com
    'All Rights Reserved by msaccesstips.com
    '------------------------------------------------------
    Dim strsql0 As String, crit As String, strsql As String
    Dim db As Database, qryDef As QueryDef, crit0 As String
    Dim strOrders As String, xoutlist As ListBox, listcount As Integer
    Dim j As Integer

    strsql0 = "SELECT Orders.* FROM Orders "
    crit0 = "WHERE (((Orders.OrderID) In ("

    Set xoutlist = Me.List2
    listcount = xoutlist.listcount - 1
    If listcount < 0 Then
    strsql = strsql0 & ";"
    GoTo nextstep
    End If

    For j = 0 To listcount
    If Len(strOrders) = 0 Then
    strOrders = xoutlist.Column(0, j)
    Else
    strOrders = strOrders & "," & xoutlist.Column(0, j)
    End If
    Next
    strsql = strsql0 & crit0 & strOrders & "))); "
    nextstep:
    Set db = CurrentDb
    Set qryDef = db.QueryDefs("OrdersoutQ")
    qryDef.Sql = strsql
    db.QueryDefs.Refresh
    DoCmd.OpenQuery "OrdersOutQ", acViewNormal
    End Sub


  12. Display the Property Sheet of the Command Buttons and check whether the setting [Event Procedure] is appearing in the On Click property. If not then select [Event Procedure] from the drop down list at the right side and save the Form.



  13. Open the Form in normal view and click on any number of items one by one in the first List Box and Click the Command Button with the > indicator. The selected items will move from the first list into the second one.


  14. Select one or two items from the right side List Box and click the Command Button with the < indicator. The selected items will move back into the end of the first list. You may try the selection method this way few more times.


  15. When you have completed the selection process click the Preview Orders Command Button.



The OrderOUTQ Query will open in Datasheet View with the filtered data with the selected Order Numbers. You can use this Query for preparing reports or design Form to display the contents or use it as source for other processing steps.


If the right side List Box is empty when you click the Preview Orders command button the OrderOUTQ Query will pick all the Items from the OrdersINQ for Output.



Refresh Dependant Combo Box Contents
Filtering Data for Different Users
Crosstab Union Queries for Charts
Union Query
Percentage on Total Query

Labels:

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Friday, May 09, 2008

Selected List Box Items and Dynamic Query

Billing Department of Northwind Traders processes their Orders selectively for shipment of materials. An Order Selection Screen has been provided with a List Box on which they can highlight the Order Numbers, Filter the selected Orders from the main file and prepare Customer Invoices and Shipping Documents. They must be able to process all the Orders appearing in the list as well.


The items appearing in the List Box themselves are records selected from within a Date-Range from the Main Order File. By creating two text controls for start-date and end-date values we can control the selection of records for the list box, if needed. But for now, we will work with items selected from the List Box, for simplicity.


We need the Orders Table from the Northwind.mdb sample Database for our example.


  1. Import the Orders Table from the sample Database NorthWind.mdb, if it is not already done in our earlier examples. If you are not sure about the exact location of this Database on your PC, visit the page: Saving Data on Form not in Table for its location references.


  2. Copy and paste the following SQL String into a new Query's SQL editing window and save the Query with the Name OrdersINQ



  3. SELECT Orders.*
    FROM Orders
    WHERE (((Orders.OrderDate) Between #5/1/1998# And #5/31/1998#));


    With the above Query we are selecting all the Orders for the Month of May 1998 for the List Box items. The criterion is set as a constant in the Query.


  4. Copy and paste the following SQL string into another Query's SQL editing window and save it with the Name OrdersOUTQ


  5. SELECT Orders.*
    FROM Orders
    WHERE (((Orders.OrderID) In (11071)));


    The second Query definition will be changed (the criteria part) dynamically based on the selection of items from the List Box.


  6. Open a new Form in Design View.


  7. If the Toolbox is not visible click the Toolbox button on the Toolbar above or select Toolbox from View Menu.


  8. Ensure that the Control Wizard button (top right button on the Toolbox) is selected. Select the List Box Control on the Toolbox and draw a List Box on the Form as shown in the design image below.


  9. List Box Design Image

  10. On the List Box Wizard ensure that the 'I want the List box to look up the values in a Table or Query' is selected and Click Next.


  11. Select Queries Option in the next view to display the Queries List. Scroll down the list and find the Query with the name OrdersINQ, select it and then click Next.


  12. Select the Fields OrderID and CustomerID from the Available Fields list and move them to the Selected List window, click Next and then click Finish.


  13. Align the List Box and its child Label as shown in the sample design above.


  14. Click on the List box and display the Property Sheet (View - -> Properties) and change the following property Values as given below:



  15. • Name = List1
    • Multi Select = Simple


  16. De-select the Control Wizard Button on the Toolbox and select the Command Button Tool and draw a Command Button underneath the List Box.


  17. Select the Command Button, display the Property Sheet, if it is not visible, and change the following property Values:


    • Name = cmdView
    • Caption = View Orders



  18. Create another Command Button to the right of earlier one. Display the Property Sheet and change the following Property Values:


  19. • Name = cmdReset
    • Caption = Reset

  20. Display the Code Module of the Form (View - - > Code). Copy and paste the following VBA Code into the Form Module and save the Form.



  21. Private Sub cmdview_Click()
    ‘-----------------------------------------------------------------------
    ‘Author : a.p.r. pillai
    ‘Date : 01/05/2008
    ‘URL : www.msaccesstips.com
    ‘All Rights Reserved by msaccesstips.com
    ‘-----------------------------------------------------------------------
    Dim strsqlO As String, crit As String, strsql As String
    Dim db As Database, qryDef As QueryDef
    Dim strOrders As String, xoutlist As ListBox, listcount As Integer
    Dim j As Integer, selectcount As Integer

    strsql0 = "SELECT OrdersINQ.* FROM OrdersINQ "
    crit = "WHERE (((OrdersINQ.OrderID) In ("

    Set xoutlist = Me.List1
    listcount = xoutlist.listcount - 1

    strOrders = "": selectcount = 0
    For j = 0 To listcount
    If xoutlist.Selected(j) = True Then
    selectcount = selectcount + 1
    If Len(strOrders) = 0 Then
    strOrders = xoutlist.Column(0, j)
    Else
    strOrders = strOrders & ", " & xoutlist.Column(0, j)
    End If
    End If
    Next

    If selectcount = 0 Then
    strsql = Trim(strsql0) & ";"
    Else
    strsql = strsql0 & crit & strOrders & "))); "
    End If

    Set db = CurrentDb
    Set qryDef = db.QueryDefs("OrdersOUTQ")
    qryDef.Sql = strsql
    db.QueryDefs.Refresh
    DoCmd.OpenQuery "OrdersOUTQ", acViewNormal

    Set db = Nothing
    Set qryDef = Nothing
    End Sub



    Private Sub cmdReset_Click()
    ‘-----------------------------------------------------------------------
    ‘Author : a.p.r. pillai
    ‘Date : 01/05/2008
    ‘URL : www.msaccesstips.com
    ‘All Rights Reserved by msaccesstips.com
    ‘-----------------------------------------------------------------------
    Dim xoutlist As ListBox, j As Integer
    Dim listcount As Integer

    Set xoutlist = Me.List1
    listcount = xoutlist.listcount - 1
    For j = 0 To listcount
    If xoutlist.Selected(j) = True Then
    xoutlist.Selected(j) = False
    End If
    Next
    End Sub


  22. Open the Form in Normal View. Click on few Orders one by one in the List Box to select them. You can click on the selected item again to de-select it or click on the Reset Command Button to de-select all.


  23. Click on the View Orders Command Button to redefine the second Query OrdersOUTQ and open it to show the selected Orders in Datasheet View.



If you need all items in the List for output then Click View Orders Command Button without making any selection or after clicking Reset Command Button.
You can use the OrdersOutQ Query with selected items as Source to link with other Queries or related Tables and design Reports to print Invoices or Design Screen to display selected Order Details.



Filtering Data for Different Users
Crosstab Union Queries for Charts
Union Query
Percentage on Total Query
Selecting Office Assistant

Labels:

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Friday, April 11, 2008

Transparent Command Button

Command Buttons can be kept hidden on Forms by setting their Transparent or Visible Property to No and make them visible to click, when certain condition is met or when a particular User opens the Form.


For example, when a Form with Data is routed through Networks to different Users (in a Secured Database) for verification, Approval of the contents, different Command Buttons can be created and programmed for each user and make them visible only when the respective User opens the Form or subject to t