⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch06.htm

📁 Microsoft_Access_97_Quick_Reference.zip
💻 HTM
📖 第 1 页 / 共 5 页
字号:
			<BLOCKQUOTE>
			<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>When you use a table or query for
			the source of the combo box list, you often want to store the value of the <I>primary
			key</I> in a field on your form. The primary <I>key field</I> needs to be one of
			the fields you choose during the wizard setup. However, you can set the Column Width
			property to 0. Then, after you move off this field in Form View, the second field
			of the Row Source is visible. 
<HR>


			</BLOCKQUOTE>

			<H2><FONT COLOR="#000077"><B>Controls: Combo Box Not in List</B></FONT></H2>
			<P>To limit the user to values in the <I>combo box</I>, choose Yes on the Limit To
			List property. If the user types a value that is not in the list, you can have Access
			give the standard error message or create a procedure to run. For more help on procedures,
			see the Special Features and Programming part of this book.
			<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
			<OL>
				<B>1.</B> In <I>Design View</I> of the <I>form</I>, right-click the combo box and
				choose <U>P</U>roperties.
				<P><B>2.</B> Move to the On Not In List property (on the <I>Event</I> tab), click
				the build button (...) on the right and double-click <I>Code</I> Builder. You will
				enter the <I>VBA</I> code window in a procedure with your <TT>C</TT>ontrolname<TT>_NotInList</TT>.</P>
				<P><B>3.</B> Type your code. Notice that the procedure has two variables, <TT>NewData</TT>
				and <TT>Response</TT>. <TT>NewData</TT> contains whatever you typed in the combo
				box. <TT>Response</TT> is for your return value whether you want the default error
				message to be returned or skipped. Use <TT>Response = acDataErrContinue</TT> if you
				want to skip the message or <TT>Response = acDataErrDisplay</TT> if you want the
				default error message.</P>
				<P><B>4.</B> Click the <I>Compile </I>Loaded Modules button, close the code window,
				and test your procedure.
			</OL>


			<BLOCKQUOTE>
			<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>For an example of the <TT>NotInList</TT>
			code, see the <TT>CategoryID</TT> <I>field</I> on the <TT>EnterorEditProducts</TT>
			form in the Solutions <I>database</I>. The example databases are in the Office or
			Access directory in the Samples folder (for example, C:\Office\Samples). 
<HR>


			</BLOCKQUOTE>

			<H2><FONT COLOR="#000077"><B>Controls: Command Button Create</B></FONT></H2>
			<P><I>Command buttons</I> are common in forms and enable you to go to another <I>form</I>,
			preview a <I>report</I>, perform <I>record</I> navigation tasks, and more. Command
			buttons are the primary method for moving a user through a series of options. Command
			buttons can be part of a form with other controls or the form can consist only of
			command buttons. This kind of form is called a switchboard form.
			<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
			<OL>
				<B>1.</B> From the <I>Design View</I> of a form, click the <I>Toolbox</I> if necessary
				and make sure the <I>Control</I> Wizards button is selected.
				<P><B>2.</B> Click the Command Button tool on the toolbar and click in the form where
				you want the button to appear. The Command Button Wizard opens.</P>
				<P><B>3.</B> Choose the category and action to perform from the first step of the
				wizard. Choose <U>N</U>ext.</P>
				<P><B>4.</B> Type the text you want to appear on the button or choose a picture.
				If you want to see more pictures, check the Show All Pictures <I>check box</I>. Choose
				<U>N</U>ext.</P>
				<P><B>5.</B> Type a name for your button on the last step of the wizard. A good convention
				is to start the name with <B>cmd</B> and then give the button a meaningful name such
				as <B>cmdPreviewEmployees</B>.
			</OL>
			<P>If you want to view or edit the <I>code</I> created by the wizard, right-click
			the button in Form Design View and choose Build <CITE>E</CITE><I>vent</I>. The code
			procedure's name is the buttonname<TT>_click</TT>.
			<H2><FONT COLOR="#000077"><B>Controls: Copy</B></FONT></H2>
			<P>If you are creating a series of the same type of controls, you can copy the <I>controls</I>
			and move them on your <I>form.</I> (See also &quot;Controls: Move).&quot; Copying
			controls works especially well for lines and <I>command buttons</I> to create uniformly
			sized objects.
			<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
			<OL>
				<B>1.</B> From the <I>Design View</I> of a form or <I>report</I>, select the control
				to copy.
				<P><B>2.</B> Choose <U>E</U>dit, Dup<U>l</U>icate.</P>
				<P><B>3.</B> Move the new control to the desired position.
			</OL>


			<BLOCKQUOTE>
			<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>You can also select the control
			and click the Copy button. Move to the new location (including a different form or
			report) and choose the Paste button. 
<HR>


			</BLOCKQUOTE>

			<H2><FONT COLOR="#000077"><B>Controls: Data Source</B></FONT></H2>
			<P>If you create a <I>control</I> and later need to change the <I>field</I> that
			it refers to, you can change the <I>Data Source</I> <I>property</I>. This might be
			necessary if you copied the <I>form</I> or <I>report</I> (see also &quot;Database
			Object: Copy&quot; in the File Management part of this book) and changed the <I>Record</I>
			Source property to a different <I>table</I> or <I>query</I>. You might also need
			to change the Data Source property if you copied the control. (See also &quot;Controls:
			Copy.&quot;)
			<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
			<OL>
				<B>1.</B> In Design View of a form or report, double-click a control.
				<P><B>2.</B> Move to the Control Source property (on the Data tab) and click the
				drop-down arrow to choose a different field.</P>
				<P><B>3.</B> If the control is a calculated <I>expression</I>, type an equal sign
				(<B>=</B>) and then type the expression or click the build button (...) and use the
				Expression <I>Builder</I>.
			</OL>
			<P>For more help on the expression builder, see &quot;Expression: Using the Builder&quot;
			in the Calculations part of this book.
			<H2><FONT COLOR="#000077"><B>Controls: Defaults Change</B></FONT></H2>
			<P>Each <I>control</I> has its own default <I>properties</I>. For example, when you
			select a <I>text box</I> control and click in the design area, the <I>label</I> associated
			with the control normally appears to the left of the text box. You can change the
			label properties of the text box as well as other default properties on controls
			you add.
			<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
			<OL>
				<B>1.</B> In the <I>Design View</I> of a <I>form</I> or <I>report</I>, click the
				<I>Toolbox</I> button on the toolbar if the Toolbox is not showing.
				<P><B>2.</B> Click the button in the Toolbox and then click the Properties button
				on the toolbar.</P>
				<P><B>3.</B> Change the properties for all controls of this type in the Properties
				sheet.
			</OL>
			<P>The default is set for all controls of this type for this form or report only.


			<BLOCKQUOTE>
			<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>To set defaults for all forms or
			reports in the <I>database</I>, create a template. Create a form or report with all
			the settings for the default controls and background colors. Save the form. Then
			choose <U>T</U>ools, <U>O</U>ptions, click the Forms/Reports tab. In the <U>F</U>orm
			Template or Report Te<U>m</U>plate text box, type the name of the form or report.
			If you want to use the templates for other databases, copy them into each database
			you need to use the defaults. For more information on templates, see &quot;Forms
			and Reports: Default Template.&quot; 
<HR>


			</BLOCKQUOTE>

			<H2><FONT COLOR="#000077"><B>Controls: Delete</B></FONT></H2>
			<P>When you no longer need a control on a form or report, you can delete it. Deleting
			the control does not delete the underlying data in the <I>table</I>. However, if
			the <I>field</I> is required or used in table <I>validation</I> rules, you won't
			be able to save the <I>record</I>.
			<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
			<OL>
				<B>1.</B> In Design View of a form or report, select one or more controls. Press
				Delete. Any labels attached to the data control are also deleted.
				<P><B>2.</B> To delete only the attached <I>label</I>, select the label and press
				Delete. You cannot delete a control with an attached label and leave the label.
			</OL>
			<H2><FONT COLOR="#000077"><B>Controls: Display or Hide</B></FONT></H2>
			<P>In some instances, you might need to hide a <I>control</I> on a <I>form</I> or
			<I>report</I>. You might need to use the value for calculations or programming.
			<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
			<OL>
				<B>1.</B> In <I>Design View</I> of a report or form, right-click the control and
				choose <U>P</U>roperties.
				<P><B>2.</B> Move to the Visible <I>Property</I> (on the Format tab). Choose No to
				hide the control or Yes to display the control.
			</OL>


			<BLOCKQUOTE>
			<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>To hide a control programmatically,
			type <B>Controlname.Visible = False</B>. To display the control, type <B>Controlname.Visible
			= True</B>. 
<HR>


			</BLOCKQUOTE>

			<H2><FONT COLOR="#000077"><B>Controls: Font Size and Face</B></FONT></H2>
			<P>Font attributes such as typeface and size provide legibility for your forms and
			reports as well as make the document attractive. To change the text attributes of
			any control (label, <I>text box</I>, <I>combo box</I>, <I>list box</I>, and so on),
			you can use the buttons on the Formatting (Form/Report) toolbar. You can also use
			the properties of the control.
			<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
			<OL>
				<B>1.</B> In the Design View of a form or report, select the control(s) you want
				to format.
				<P><B>2.</B> Click the Bold, Italic, or Underline buttons to apply that formatting.</P>
				<P><B>3.</B> Click the Font button's down arrow and choose a different typeface.</P>
				<P><B>4.</B> Click the Font Size button's down arrow and choose a different font
				size.
			</OL>


			<BLOCKQUOTE>
			<P>
<HR>
<FONT COLOR="#000077"><B>TIP:</B></FONT><B> </B>If the font is too big for the control,
			use F<U>o</U>rmat, <U>S</U>ize, To <U>F</U>it to change the control size to fit the
			text. 
<HR>
</P>
			<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>To change the formatting of the
			control programmatically, look at the format properties on the <I>Property</I> sheet.
			The <I>code</I> for the property is without a space. To change the font size, you
			would type the code <B><I>controlname</I>.FontSize = 14</B>. 
<HR>


			</BLOCKQUOTE>

			<H2><FONT COLOR="#000077"><B>Controls: Labels Create</B></FONT></H2>
			<P>Labels are automatically created with controls such as text boxes, combo boxes,
			and so forth. The label itself is a control with its own control properties. They
			direct the user where to input text or what the data means. There are some instances
			where you want to add additional labels to a <I>form</I> or <I>report</I>. You can
			add a title to the form or report header and also replace a <I>label</I> that you
			deleted.
			<H3><FONT COLOR="#000077"><B>Steps</B></FONT></H3>
			<OL>
				<B>1.</B> In <I>Design View</I> of a form or report, click the Label button on the
				<I>Toolbox</I>.
				<P><B>2.</B> Click in the design area where you want the label to go.</P>
				<P><B>3.</B> Type the text for the label.
			</OL>
			<P>To edit the label, click once to select the <I>control</I> and click a second
			time to enter edit mode. You can also change the <I>Caption</I> property on the Property
			sheet.


			<BLOCKQUOTE>
			<P>
<HR>
<FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>The default is for a label to be
			created with data controls. However, you can turn off this feature by clicking the
			<I>Text Box</I> control in the Toolbox, clicking the Properties button, and changing
			the Auto Label property (on the Format Tab) to No. Please note that the items on
			the Format tab of the Default Text Box are not alphabetically listed. You have to
			scroll down to find the Auto Label property. 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -