In this article

Understanding offline forms

You might need to design a Microsoft Office InfoPath form template that users can fill out while their computers are disconnected from the network. For example, you can design a form template that an insurance adjuster can use in the field while investigating a claim. The form template contains secondary data connections that provide data to the form from an external database. The adjuster needs this data in order to fill out the form. While still in the office and connected to the network, the insurance adjuster can create a form based on this form template, and then save the form on his or her computer. In the field, the adjuster can then open and fill out the form without being connected to a network. After returning to the office and reconnecting to the network, the adjuster can then submit the form.

By default, a form saved on a computer can work without a network connection. When a user creates a form based on a form template, InfoPath downloads and stores a copy of that form template on the user’s computer. Whenever the user opens a form based on that form template, InfoPath first checks if there is a network connection to the computer. If a network connection exists, InfoPath checks the location where the form template was downloaded from, to determine if there is an updated version of the form template. If an updated version exists, InfoPath updates the form template on the user's computer. If a network connection does not exist, InfoPath uses the version of the form template that is stored on the user's computer.

In order to design a form template for offline use, the form template must be stored on the user's computer, and any data that is required by the user to complete the form, such as items in a list box, must be available to the user even if the computer is not connected to the network. The data in these controls are supplied from a secondary data connection to an external data source. This data can be stored in the user's computer in either the form template or in a special storage location called the cache.

When you add a secondary data connection to a form template that queries data from an external data source, InfoPath sends a query to that external data source. The results of the query are then stored in the form template. When the user creates a new form based on this form template, the data saved to the form template is available to the user.

When the form uses this secondary data connection to update the contents of a list box or combo box control with the latest data from the external data source, InfoPath stores the results of this query in a special storage location called the cache, if the computer is connected to a network. InfoPath uses the data in this cache to supply data to those controls.

To make the data from a secondary data connection available to your users, even if their computers are not connected to a network, you can do one or both of the following:

  • Store the data from the external data source in the form template.

  • Use the secondary data connection when the form opens.

After configuring the secondary data connection to work while the user's computer is offline, you can also configure the form template to retrieve the latest data from the external data source. You can configure the form template to retrieve the latest data (by limiting the availability of the existing data in the form to a specified number of days) and then adding a button to get the latest data.

Store the data in the form template

You can store the data from a secondary data connection in a form template by selecting the Store a copy of the data in the form template check box in the Data Connection Wizard when you create the secondary data connection.

When you select this check box, InfoPath uses the data connection to retrieve data from the external data source. It then stores this data in the form template. When a user creates a form or opens an existing form based on your form template, a copy of the form template, along with the stored data, is downloaded to the user's computer. If the user's computer is connected to a network when the form is created, InfoPath retrieves data from the external data connection whenever the form uses this data connection. If the user is not connected to a network when the form is created, InfoPath uses the data that is stored in the form template on the user's computer.

Because the data was retrieved at the time that the data connection was created, the external data source may have been updated by the time a user creates a form based on this form template. If you want your users to receive the latest data from an external data source when they create a new form or open an existing form based on your form template, you should design your form to use a secondary data connection when the form first opens.

Use the secondary data connection when the form opens

If you want your users to receive the latest data from an external data source, rather than using the data stored in a form template, select the Automatically retrieve data when form is opened check box in the Data Connection Wizard when you create the secondary data connection.

When a user creates a new form while connected to the network, InfoPath uses this secondary data connection to retrieve the latest data from the external data source. This data is stored in the cache. If the user opens an existing form that is saved on their computer, InfoPath checks if the computer is connected to a network. If the computer is connected to a network, InfoPath retrieves the latest data from the external data source by using this data connection. If the user is working offline, InfoPath uses the data stored in the cache or in the form template.

Security Note: The data retrieved from a secondary data source is stored in the computer as plain text. If you are using a secondary data connection to retrieve sensitive data from an external data source, you may want to disable this feature to help protect the data from unauthorized use in case the computer is lost or stolen. If you disable this feature, the data will be available only if the user is connected to the network.

Get the latest data

If an external data source is regularly updated, you can configure a form template to allow users to retrieve the latest data through the secondary data connection. To do this, you can limit the availability of the data that is currently stored in the cache to a specified number of days, and then you can add a button to retrieve data from any external data sources by using all of the secondary data connections in the form. Doing this helps ensure that users are working with the most recent data.

Alternatively, you can limit the availability of data from a secondary data connection by setting an expiration date on how long that you want data to be stored on a user's computer.

When you use this option, InfoPath makes the data from all secondary data connections available to the form for only the specified number of days. After that number of days has passed, the data will not appear in the form. You can then add a button to your form that users can click to retrieve data, by using a specific secondary data connection or all of the secondary data connections in the form.

Security Note: Even if the data is not available to the form, the data remains on the user’s computer after the set number of days has passed. The data will only be overwritten when the operating system uses this space to store something else.

Top of Page

Create a data connection to a SQL database for offline use

Before you add a secondary data connection to a Microsoft SQL Server database to your form template, you need the following information from your database administrator.

  • The name of the server where the database that you will use with this form template is stored.

  • The name of the database that you will use with this form template.

  • The authentication required by the database. The database can use either Microsoft Windows authentication or SQL Server authentication to determine how users can access the database.

  • The name of the table that contains the data that you want to send to the form. This is the primary table. If you plan to use more than one table in the database, you need the names of those other, child tables. You also need the names of the fields in the child tables that possess relationships to the fields in the primary table.

  • Whether you can safely store the query results in the form for offline use.

Once you get this information, you can use the following procedure to create the data connection to a SQL database for offline use.

  1. On the Tools menu, click Data Connections.

  2. In the Data Connections dialog box, click Add.

  3. In the Data Connection Wizard, click Create a new connection to, click Receive data, and then click Next.

  4. On the next page of the wizard, click Database (Microsoft SQL Server or Microsoft Office Access only), and then click Next.

  5. On the next page of the wizard, click Select Database.

  6. In the Select Data Source dialog box, click New Source.

  7. In the What kind of data source do you want to connect to list, click Microsoft SQL Server, and then click Next.

  8. In the Server name box, type the name of the server where the database is stored.

  9. Under Log on credentials, do one of the following:

    • If the database determines who has access to the server based on the credentials used in a Microsoft Windows network, click Use Windows Authentication.

    • If the database determines who has access to the server based on a specified user name and password that you get from the database administrator, click Use the following User Name and Password, and then type that user name and password in the User Name and Password boxes.

  10. Click Next.

  11. On the next page of the wizard, in the Select the database that contains the data you want list, click the database that you want to use, select the Connect to a specific table check box, click the name of the primary table, and then click Next.

  12. On the next page of the wizard, in the File Name box, type a name for the file that stores the data connection information.

  13. To save these settings, click Finish.

  14. Add any other tables that you want to use in the query data connection.

    How?

    1. Click Add Table.

    2. In the Add Table or Query dialog box, click the name of the child table, and then click Next. InfoPath attempts to set the relationships by matching field names in both tables. If you do not want to use the suggested relationship, select the relationship, and then click Remove Relationship. To add a relationship, click Add Relationship. In the Add Relationship dialog box, click the name of each related field in the respective column, and then click OK.

    3. Click Finish.

    4. To add additional child tables, repeat these steps.

  15. Click Next.

  16. If you want the data from this secondary data connection to be available even if a user's computer is not connected to a network, select the Store a copy of the data in the form template check box. When you select this check box, InfoPath queries the external data source and stores the results in the form template.

    Security Note: Selecting this check box stores the query results in the form template. Because the data is stored in the form template, it is available in the forms that users fill out, even if their computers are not connected to a network. If you are getting sensitive data from this data connection, you may want to disable this feature to help protect the data in case the computer is lost or stolen.

  17. Click Next.

  18. On the next page of the wizard, type a descriptive name for this secondary data connection. Verify that the information in the Summary section is correct. To allow your users to use this secondary data connection when they create a new form or open an existing form based on this form template, select the Automatically retrieve data when form is opened check box.

Top of Page

Create a data connection to an Access database for offline use

Before you add a secondary data connection to an Access database to your form template, you need the following information from your database administrator.

  • The name and location of the database.

    Note: You will also need to know whether the database is in a network location that is accessible to your users. If other users on the network will create forms based on this form template, your database must be located in a network location that is accessible to your users.

  • If your form template will only query the database, you will need the name of the table that supplies the results of the query sent to the database. This table will be the primary table when you configure the query data connection.

  • The names of any other tables that the primary table may require data from. In most cases, the table relationships are already established in the database. If you must establish the relationships between the primary table and another table, you will need the related field names in both tables.

Once you get this information, you can use the following procedure to create the data connection to an Access database for offline use.

  1. On the Tools menu, click Data Connections.

  2. In the Data Connections dialog box, click Add.

  3. In the Data Connection Wizard, click Create a new connection to, click Receive data, and then click Next.

  4. On the next page of the wizard, click Database (Microsoft SQL Server or Microsoft Office Access only), and then click Next.

  5. On the next page of the wizard, click Select Database.

  6. In the Select Data Source dialog box, browse to the location of your database.

    Note: If your database is stored in a network location, browse to the UNC path of the location. Do not browse to the network location through a mapped network drive. If you use a mapped network drive, the forms created based on this form template will search for the database from a mapped network drive. If the user does not possess a mapped network drive, the form will not find the database.

  7. Click on the name of your database, and then click Open.

  8. In the Select Table dialog box, click the primary table that you want to use, and then click OK.

  9. On the next page of the wizard, select the Show table columns check box.

    By default, all of the fields in the table will be added to the main data source of the form template.

  10. Under Data source structure, clear the check boxes for the fields that you do not want to include in the main data source.

    Add any other tables or queries that you want to use in this data connection.

    How?

    1. Click Add Table.

    2. In the Add Table or Query dialog box, click the name of the child table, and then click Next. InfoPath attempts to set the relationships by matching field names in both tables. If you do not want to use the suggested relationship, select the relationship, and then click Remove Relationship. To add a relationship, click Add Relationship. In the Add Relationship dialog box, click the name of each related field in the respective column, and then click OK.

    3. Click Finish.

    4. To add additional child tables, repeat these steps.

  11. Click Next.

  12. To make the data from this secondary data connection available even if a user's computer is not connected to a network, select the Store a copy of the data in the form template check box. When you select this check box, InfoPath queries the external data source and stores the query results in the template.

    Security Note: Selecting this check box stores the query results in the form template. Because the data is stored in the form template, it is available in the forms that users fill out, even if their computers are not connected to a network. If you are getting sensitive data from this data connection, you may want to disable this feature to help protect the data in case the computer is lost or stolen.

  13. Click Next.

  14. On the next page of the wizard, type a descriptive name for this secondary data connection. Verify that the information in the Summary section is correct. To allow your users to use this secondary data connection when they create a new form or open an existing form based on this form template, select the Automatically retrieve data when form is opened check box.

Top of Page

Create a data connection to a SharePoint document library for offline use

Before you add a secondary data connection to your form template, you need the following information from your site administrator.

  • The location of the Microsoft Windows SharePoint Services site, and the necessary permissions to access it.

  • Verification that the site is configured so that your users can access data from the document library or list.

  • Verification that you can store the data from the document library or list on your users' computers for offline use.

Once you get this information, you can use the following procedure to create the data connection to an Access database for offline use.

  1. On the Tools menu, click Data Connections.

  2. In the Data Connections dialog box, click Add.

  3. In the Data Connection Wizard, click Create a new connection to, click Receive data, and then click Next.

  4. On the next page of the wizard, click SharePoint library or list, and then click Next.

  5. On the next page of the wizard, type the URL of the SharePoint site with the document library or list, and then click Next.

  6. On the next page of the wizard, in the Select a list or library list, click the list or library that you want to use, and then click Next.

  7. On the next page of the wizard, select the check boxes next to the fields that will supply data to the form template. If the form template will be published to the document library, and you want forms that are based on this form template to retrieve metadata about the form, select the Include data for the active form only check box.

  8. Click Next.

  9. To make the data from this secondary data connection available even if a user's computer is not connected to a network, select the Store a copy of the data in the form template check box. When you select this check box, InfoPath queries the external data source and stores the query results in the form template.

    Security Note: Selecting this check box stores the query results in the form template. Because the data is stored in the form template, it is available in the forms that users fill out, even if their computers are not connected to a network. If you are getting sensitive data from this data connection, you may want to disable this feature to help protect the data in case the computer is lost or stolen.

  10. Click Next.

  11. On the next page of the wizard, type a descriptive name for this secondary data connection, and then verify that the information in the Summary section is correct.

  12. To allow your users to use this secondary data connection when they create a new form or open an existing form based on this form template, select the Automatically retrieve data when form is opened check box.

Top of Page

Configure data availability

If your external data source is regularly updated with new data, you can configure the form template to make any cached data available. This data is available to forms based on this form template for a limited number of days that corresponds to the update schedule of the external data source. By limiting the number of days that the data is available to forms based on this form template, you can require that your users update the data from the external data source on a regular basis.

To update the data, you can add a button to your form template that users can click to update the data from all of the secondary data connections used in the form template.

Note: If you use a button to refresh the data connection, tell your users to click this button only if they are connected to a network.

Specify the number of days cached data is available

This setting applies to all of the secondary data connections in the form template.

  1. On the Tools menu, click Form Options.

  2. In the Category list, in the Form Options dialog box, click Offline.

  3. Under Offline, select the Store data returned from queries so it can be used in Offline Mode check box.

  4. Click Stored queries expire after this number of days.

  5. In the list, select the number of days that you want the cached data to be available to the form.

Add a button to refresh the data connection

  1. If the form template has multiple views, click View name on the View menu to go to the view with the control where you want to display the data from the secondary data source.

  2. If the Controls task pane is not visible, click More Controls on the Insert menu, or press ALT+I, C.

  3. Drag a button control onto your form template.

  4. Double-click the button control that you just added to the form template.

  5. Click the General tab.

  6. In the Action list, click Refresh.

  7. In the Label box, type the name that you want to appear on the button.

  8. Click Settings.

  9. In the Refresh dialog box, do one of the following:

    • To configure the button to retrieve the latest data through this data connection, click One secondary data source.

    • To configure the button to retrieve the latest data through all of the secondary data connections, click All secondary data sources.

  10. In the Choose the secondary data source list, click the secondary data source that is associated with the query data connection.

  11. Click OK to close all of the open dialog boxes.

  12. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

Top of Page

Disable offline use

In some cases, you will want to design a form template to only allow users to fill out a form when they are connected to a network. For example, if your form template has a data connection to an external data source that contains sensitive or confidential data, you may want to configure the form template to allow forms to be filled out in a connected state only. By configuring the form template in this manner, you can help protect the data in case the computer is lost or stolen, because the data is not being stored on the user's computer.

To configure the form template to allow users to fill out the form, only if their computer is connected to a network, complete the following steps.

  1. On the Tools menu, click Form Options.

  2. In the Category list, in the Form Options dialog box, click Offline.

  3. Under Offline, clear the Allow users to fill out this form if data is unavailable check box.

Top of Page

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.