<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;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F&amp;blogLocale=en_US&amp;homepageUrl=http%3A%2F%2Fwww.msaccesstips.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" allowtransparency="true" title="Blogger Navigation and Search"></iframe> <div></div>
www.msaccesstips.com

LEARN MS-ACCESS TIPS AND TRICKS


International Response Fund

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Friday, February 27, 2009

Synchronized Floating popup Form

This Form is designed specifically for inquiry purposes (not for Data Entry). The Source Data Table has several fields and the information in them can be categorized into different groups for viewing.


For example, the Employees Form, in Northwind.mdb sample database, has been divided into two parts, viz. Company Information and Personal Information. The Company Info part is designed on the first Page of a Tab Control and the second part Personal Info category of fields are placed on second page of the Tab Control and stays hidden till it receives a click on the second page of the Tab Control, to bring the data into view. Let us assume that the Company Info is the most frequently viewed or updated information and it is kept in full view and Personal Info kept behind because it is not so often viewed or updated.


We will design them differently with an interesting trick involving two separate stand alone Forms without linking them as Main Form and Sub-Form. Company Info on one Form and Personal Info on a separate Form but both will have source data from Employees Table.


Let us name them as EmployeeMain and EmployeeSub Forms. They will remain as two independent Forms. A sample image of both Forms in running mode is given below:


Sample Run Image

The trick is that when we open the EmployeeMain Form it will show only the Company Info alone (no trick here). We will move few records forward using the Record Navigation Button and at this point we would like to see the Personal Info part of the current record. We will click on a Command Button to open the EmployeeSub Form with the Personal Info of the current record on the EmployeeMain Form. From this point onwards the records on both Forms move forward/back synchronized, when you move to Next or Previous records on the EmployeeMain Form, even though they are two separate Forms.


The EmployeeSub Form is defined as a Pop Up Form (or its Pop up Property value is set to Yes) to float it above the EmployeeMain Form or any other Form open in the Application Window, provided if you don't open another Pop Up Form. If you don't want the EmployeeSub Form to stay on you may close it and open again when needed using the Personal Info Command Button on the EmployeeMain Form. When you close the EmployeeMain Form this action will close the EmployeeSub Form too, if it is running.


  1. We can very easily design these two Forms by importing the Employees Table and Employees Form from C:\Program Files\Microsoft Office\Office11\Samples\Northwind.mdb Database. If you have not used these Objects so far for any other examples given on this site you may import them into your database now.

  2. Open the Employees Form in Design View.

  3. Click on the Form and drag the mouse over all Controls on the Company Info Tab except the Photo (if you want it you may select that too) and the Command Button controls.

  4. Select Copy from Edit Menu.

  5. Click on the Employees Table and select Form from Insert menu and select Design View from the list of options displayed, to create a new Form.

  6. Click on the Detail Section of the Form and select Paste from Edit Menu to place the copied fields of Employees Form on to the new Form.

  7. If the Form Header/Footer Sections of the Form are not visible then select Form Header/Footer from View Menu.

  8. Copy and Paste the Text Control with the employee name expression from the Header Section of the Employees Form to the Header Section of your Form. Change the Font Color to Red or some other Color you like.

  9. Create a Command Button in the Detail Section below the data fields.

  10. Display its Property Sheet (View- -> Properties).

  11. Change the Name Property Value to cmdPersonalInfo and the Caption Property Value to Personal Info.


  12. NB: You must be careful with the names of Forms and Controls I suggest here because they are used in the Programs. If you give them differently the trick may not work as expected after completion.


  13. Create a Command Button at the Footer Section of the Form.

  14. Change the Name Property value to cmdClose and the Caption Property Value to Close.

  15. Display the Form's Property Sheet. Click on the left top corner of the Form where a black rectangle is shown, at the intersection of the horizontal and vertical design guide (scales) meet, to select the Form's Property Sheet, if it is not the current one.

  16. Change the Caption Property Value to Company Info.

  17. Display the VBA Code Module of the Form (Alt+F11). Copy and Paste the following Code into the Code Module.


  18. Option Compare Database
    Option Explicit
    Dim strSQL As String


    Private Sub cmdClose_Click()
    DoCmd.Close
    End Sub

    Private Sub cmdPersonalInfo_Click()
    If IsLoaded("EmployeesSub") Then
    strSQL = "SELECT Employees.* FROM Employees "
    strSQL = strSQL & "WHERE ([EmployeeID] = " & Me![EmployeeID] & ");"
    Forms("EmployeeSub").RecordSource = strSQL
    DoCmd.SelectObject acForm, "EmployeeSub", False
    Else
    DoCmd.OpenForm "EmployeeSub", acNormal, , "[Employeeid] = " & Me![EmployeeID], acFormReadOnly, acWindowNormal
    End If

    Forms("EmployeeMain").ActiveControl.SetFocus

    End Sub

    Private Sub Form_Close()
    DoCmd.Close acForm, "EmployeeSub"
    End Sub

    Private Sub Form_Current()
    If IsLoaded("EmployeeSub") Then
    strSQL = "SELECT Employees.* FROM Employees "
    strSQL = strSQL & "WHERE ([EmployeeID] = " & Me![EmployeeID] & ");"
    Forms("EmployeeSub").RecordSource = strSQL
    DoCmd.SelectObject acForm, "EmployeeSub", False
    Forms("EmployeeMain").SetFocus
    End If

    End Sub

    Private Sub Form_Open(Cancel As Integer)
    DoCmd.Restore
    End Sub


  19. Save the Form with the name EmployeeMain.

  20. Repeat the process from Step-3 to Step-8 for transferring information from the Personal Info Tab of the Employees Form to a new Form.

  21. Display the Form Header/Footer Section of the Form (View - ->Form Header/Footer).

  22. Create a Command Button and change the Name Property Value to cmdClose and the Caption Property Value to Close.

  23. Display the Form's Property Sheet.

  24. Change the following Property Values as given below:




    • Caption = Personal Info

    • Default View = Single Form

    • Allow Additions = No

    • Allow Deletions = No

    • Data Entry = No

    • Record Selectors = No

    • Navigation Buttons = No

    • Dividing Lines = No

    • Auto Resize = Yes

    • Pop Up = Yes

    • Border Style = Dialog

    • Allow Design Changes = Design View Only.





  25. Display the Code Module of the Form (Alt+F11).

  26. Copy and paste the following Code into the Code Module.


  27. Private Sub cmdClose_Click()
    DoCmd.Close acForm, Me.Name
    End Sub

  28. Save the Form with the name EmployeeSub.


  29. We need a small program to check whether the EmployeeSub Form is in Open state or not before attempting to refresh its source data and bring it in visible state.


  30. Copy and Paste the following Code into a Global Module (Standard Module) and save the Module:



Public Function IsLoaded(ByVal strFormName As String) As Boolean
Dim j As Integer

On Error GoTo IsLoaded_Err

IsLoaded = False
For j = 0 To Forms.Count - 1
If Forms(j).Name = strFormName Then
IsLoaded = True
Exit For
End If
Next

IsLoaded_Exit:
Exit Function

IsLoaded_Err:
IsLoaded = False
Resume IsLoaded_Exit

End Function


  1. To try out your creation, open the EmployeeMain Form, click on the Record Navigation Control to advance few records forward.

  2. Click on the Personal Info Command Button. The EmployeeSub Form will open up showing Personal Information pertains to the same employee on the main Form. Check the Names of the Employee appearing on top of both forms.

  3. Now, try advancing records on the main from forward or back with the record navigation control. You will see that the corresponding personal information on the EmployeeSub Form is also moving along with the records on the main form.

  4. If you close the EmployeeMain Form while the EmployeeSub Form is open both will be closed.


You may download the sample database from the Download Link given below and give it a try before you design one of your own to understand the trick:



Download - File: SynchronizedForms2K.zip (Size:54.6K)



StumbleUpon Toolbar



Rounding Function MRound() of Excel
Custom Calculator and Eval() Function
Data Editing and Security Issues
Event Trapping & Summary on Datasheet
Sum() Min() Max() ParamArray

Labels:

0 Comments:

Post a Comment

Note:Comments subject to Review by Blog Author before displaying.

Links to this post:

Create a Link

<< Home


Creative Commons License
Learn MS-Access Tips and Tricks by msaccesstips.com is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 India License.



This Page is best viewed with 1280 x 1024 Resolution

   FEATURED LINKS
SITEMAP
Command Button Animation
3D Headings on Forms
MsgBox & Office Assistant
Reminder Ticker
MS-Access & E-Mails
Automated E-Mail Alerts
MsgBox with Options Menu
Colorful Command Buttons
Configure Lotus Notes
Alerts through Network
Running this site has become a costly affair as the revenue from Ads is not sufficient to support it. If you find these pages informative & useful and would like to extend a helping hand, then please do it here.





Link Back to us with this Button

Learn MS-Access

Copy and Paste this HTML Code in your Webpage


Add to Technorati Favorites

Programming Blogs - Blog Catalog Blog Directory
Powered by FeedBurner
Add to Google

Software
Computers blogs
TopOfBlogs




AddMe - Search Engine Optimization Submit Your Site Free!
Go BlogZ Ave Blogs
eBlogzilla Changing LINKS
LS Blogs Blogarama
blog search directory BlogUniverse
Find Blogs in Directory RSS Directory
blogskinny.com ShowcaseBlogs.com
Amfibi

Search Engine Optimization and SEO Tools
Dmegs Web Directory Takeaway for Sale Businesses For Sale
Free Submission Directory Free site submission

Free Listing
 





Free Page Rank Checker

AddThis Social Bookmark Button

Enter your email address:

Delivered by FeedBurner



Top Blogs


Microsoft Access is the Jewell among MS-Office suite of Applications. Its Security features are excellent and works fine in Network environment. MS-Access can link/upload data from any Data Source. Applications that you design should be user-friendly and visually pleasing too. Here I would like to share my experience in Microsoft Access Programming with you and I am sure that you will find them interesting too.

My Photo
Name: Ramachandran Pillai
Location: Cochin, India

I am not an Access Guru and not through MS-Access yet. More to learn and I don’t think that aspect has any end because others have their own style of using this tool. We can learn lot more tricks, other than what we already know, from others too. My programming skills in COBOL, BASIC, Turbo-C, dBase, FoxPro, Visual Basic & Basic HTML attained through self-learning. I wrote my first COBOL Program in 1975 for ICL1901, 3rd Generation Main Frame Computer. Worked as a Computer Operator (NCR VRX8555 Mainframe Machine upto 1990) with M/s. Y.B.A. Kanoo, Saudi Arabia. Started using MS-Access Ver.2 in 1996, when dBase III+ and Foxbase (later version Foxpro) were my favorite DBMS. During Last 13 Year period I have developed more than 45 In-House Applications (medium & small) under MS-Access for our Organization, a leading Automotive Company in Oman. All the Applications are fully Secured and runs under Windows Network. It is my pleasure to share my experience with others. Anything interesting that you would like to share with me, please do. My E-mail Address: aprpillai@msaccesstips.com


If you need a Demo of any of the Topic explained here, send me an E-mail to: aprpillai@msaccesstips.com
with the Topic Description, I shall try to send a sample database to you.


Access Tips | Email | Reports | Report Tricks | Graphs | Forms | Menus | Animation | Security | Internet | How TOs | Linking | Query | Progress Meter | Alerts | Process Tips | Access Functions |




Site Designed by:www.msaccesstips.com