Use table field description on form - ms-access

I would like to display a field's description on a form. How would I accomplish this? For example, table name is tblbureau, field name is Counsel with a description 'General Counsel for the Defense', form name is frmCounsel. I'd like to use a control (textbox?) that displays the full description instead of using the default label for the field name. Thanks.

If you have used the form wizards to create the form, any descriptive text is added to the StatusBarText propery. This is even true when you create a blank form and drag fields from the field list to the form. You can refer to this property for your message box, or just refer the user to the statusbar. You can also update the ControlTipText property with the StatusBarText property.
MsgBox Me.ATextBox.StatusBarText
Using the above will save coding to get the description:
Currentdb.TableDefs("atablename").Fields("afieldname").Properties("Description")
Note that the description property is not available for fields when you have not added a descrition, so the above would cause an error.

Related

Populate a ComboBox with the Result of a Text Box

I have a form in my Access database called:
formAcademyRegister
Inside this form I have a combo box called:
EmployeeCode
This combo box retrieves its data from a table called:
Employees
The primary key on this field is EmployeeID
To make it easier for the user I created a form called formsEmployeeSearch. In this form use some text fields to make it easier to search for the employee using a first name or last name, returing the values to a list box on this form. This list box has three fields:
EmployeeID
FirstName
LastName
All these fields are also populated using the Employees table so there won't be any data type issues.
Below the list box on the search form I have a button called
butUpdateEmployeeID
When the button is clicked, I want the following to happen:
The EmployeeCode combo box in the formAcademyRegister be updated with the employeeID as selected in the list in the formsEmployeeSearch form
The formsEmployeeSearch to be closed
I am comfortable with the process of closing the form, I am however struggling with the code to populate that combo box with the value selected in the list box.
I tried the following:
Me.Form!formAcademyRegister!EmployeeCode = Me!lstEmpSearchResult.Value
But this is not working.
Try the below.
Forms.formAcademyRegister.EmployeeCode.Value = lstEmpSearchResult.Value
DoCmd.Close acForm, Me.Name, acSavePrompt
A couple of notes.
The keyword Me is not required when the code is behind the form itself, but in some situations it makes the code more readable.
The .Value property is default property (where applicable) thus can be omitted. It's best practice to keep it for clarity.
Me.Form is reference to current Form (where code is).
Forms is collection. Assignement to collection item "Collection(ItemNameOrItemIndex)
Forms("formAcademyRegister").cmbEmployeeCode.Value = Me.lstEmpSearchResult

Using Dlookup in the Default Value field of a form control

I am trying to populate a form controls default value based on the value of a combobox on that form. The combobox is called Title, and I want the control HIPAA to populate based on the value of HIPAA in my table tblTrainingEventTiles where the Title selected on the form matches the title in the table.
I was putting the following code into the default value of the control on the form:
=IIf(IsNull([Title]),0,DLookUp("HIPAA","tblTrainingEventTitles","[tblTrainingEventTitles].[Title]=[Title]"))
Access seems to ignore it however. It doesn't do anything and there are no error messages. I'm not sure if my problem is with my dlookup or with the fact that I'm trying to use this in the default value field. (or both?) Does anyone have any ideas?
Try this:
=Nz(DLookUp("HIPAA","tblTrainingEventTitles","[tblTrainingEventTitles].[Title]=[Title]"),0)
If your combobox's bound column is text you should use ' around it's content. And you should concatenate value of combobox to filter part of dlookup.
=IIf(nz([Title],"")="",0,DLookUp("HIPAA","tblTrainingEventTitles","[tblTrainingEventTitles].[Title]='" & [Title] & '"))

Multiline property problems

I have a column in my database that is set to memo. I am trying to view the data in a textbox.
I have enabled new line in field from the Enter Key Behaviour property but all the data from the record is now showing - What am I missing?
The data is being pulled from a list box, example code below:
Textbox1 = listbox.column(1)
Thanks in advance
This has nothing to do with the EnterKeyBehavior property of the text box.
http://allenbrowne.com/ser-63.html
Row Source
A Memo field in the Row Source of a combo box or list box will
truncate.
Don't use memo fields in combos or list boxes.
You'll need a different method to load the text box, e.g. read the ID from the listbox and use DLookup().

Database design for a form builder in MYSQL

Currently I am working on a form builder,
the user can add input box with different name into the form.
Notice that the form will be stored as HTML code, so the only concern is the input box name storage and submit form value
Now I have draft a table like this
form
-----
id
inputs
------
form_id
name
values
-------
input_id
value
One problem I can think of is the data type of value,
the above design works only if the value is text / textarea
How to handle if the input box is file upload / radio / select?
so are there are Any better design,
thanks a lot for helping.
you have to store element type also. according to the element type,find out which html element it is and render this
You will need an extra table for radio and select, since it has multiple rows for one <input> field.
Don't forget about optional things like id=, name=, style=, class=, etc.
I predict that your finished product will be as clumsy to use as typing the form elements by hand.

How do I substitute one entry for another an MS Access report?

I recently started working with MS Access 2010, and I am trying to generate labels from a form that I have created. In the form, three pieces of information are put in by the user: style, color code, and unit of measure (UoM). The style numbers appear the same way on the form and in the report, and I have been able to get that to work.
However, for the color code, I need both the inputted color code and the actual color to show up on the report. I have a table that has all of the color codes with the corresponding color names. I cannot figure out how to get the text box that is supposed to show the color name to show it. I know virtually no SQL, but I found information on it on the internet and pieced together this code in the ControlSource for the text box the color name is supposed to be in:
=(SELECT [Description]
FROM [Color]
WHERE([Forms]![Box Label Form]![ThirdJoined]=[Color]![ColorCode]))
[Description] is the name of the column within the [Color] table that gives the actual color name.
[Box Label Form] is the name of the form.
[ThirdJoined] is the name of the input text box within the form.
[ColorCode] is the name of the column within the [Color] table that gives that color code.
This code doesn't work, and only results in #NAME appearing in Print Preview view. How can I get this to work, either code-wise or otherwise?
You cannot set the ControlSource of a textbox to a SQL statement. You could set it to a DLOOKUP function to lookup a single value. You also need to separate out the reference to the form control using concatenation (&).
=DLOOKUP("Description","[Color]","ColorCode='"&[Forms]![Box Label Form]![ThirdJoined]&"'")
I'm assuming the Color is a text-value so the form-value needs to be enclosed in apostrophes.
If this expression is used on the form [Box Label Form] then you don't need to qualify the name of the Control:
=DLOOKUP("Description","[Color]","ColorCode='"&[ThirdJoined]&"'")