Forms :: Update Database Column When Mandatory Fields Are Completed
May 11, 2013
I have a form with lots of combo boxes and text boxes. They are all linked to various MS Access tables and some of the fields are mandatory. I would like do an check to see if all the mandatory fields are not null i.e. are populated with a value and then run an update query for my master table in the database to flag the records as being complete if all the mandatory fields are populated.
If (IsEmpty(tab1.cmb_a)) Then do something
But I am just blank at the moment on how to proceed, especially on how I can do all the checks and then populate the database.
I have a table, which when i first set it up i decided that a couple of the fields had to be mandatory.
So, i set the "Required" property of the field to "Yes" (at table level - which is probably poor practice?)
I now have a form that allows a user at the front end to enter items in the table.
If they complete all the fields on the form i have used macro builder to save the record, present a nice message and move to a New Record. (3 elements in all)
However, if they try to save the record having not completed the "Required" fields then they get an error message instructing them the field is required, but then the macro crashes.
So what's the best way to approach Mandatory fields? Is it best to leave the "Required" property at table level set to No and then have something at form level which checks they have entered a value in the field? (i'm guessing this is probably the correct approach)
I tried removing the table level condition from the [Field] and adding this as the first argument of the macro builder which saves my record:
Code:
IF [Field] = "" Then MessageBox "You Must Complete Mandatory Fields" Stop Macro End If
But my macro still completes and saves the record...
I am experiencing a few problems with mandatory fields in my forms. I use different forms which all base on the same table - therefore I can not use the "Required"-flag in the table definitions.
What I managed to do by now: I put this statement into the OnExit-Event: =IIf([FMNO] Is Null,MsgBox("Please enter the FMNO",48,"Error Message"),"")
This provides me with an errormessage in case the field is null. When I exit the field, I receive the errormessage but the cursor moves to the next field. How can I make sure that the cursor stays in the field where the error occurs?
My next problem: When I try to use this syntax on a text-field (e.g. "NAME") it doesn't work.
Has anybody any suggestions?
Your help is very much appreciated, I'm getting more and more desperate on this issue.
Basically I have a form which records primary and secondary reasons for people writing off money, and in the secondary reasons I have an option for 'other', in case any of the other options aren't applicable. There is also a comments section on the form which is optional.
My issue is, I want the comments section to become mandatory if the 'other' option has been selected. I don't want it mandatory all the time, and I don't want it disabled if 'other' isn't selected, but I need to force people to write at least something in there if they have selected other.
I tried variations on code I found from other places but was unable to get this to function, and I am not sure if this can be done with validation or something like that.
We have a form, which has a field linked to a "Recipients" table through a lookup. The field is bound to the recipient's name, but the lookup displays additional columns for user to identify the correct recipient in the case of duplicate names.
The "Payment" table's Recipient field only displays the recipient's name. So where duplicates occur, it's impossible to know which recipient is the correct one associated to a payment.
I would like to add an additional field to the "Payment" table called "RecipientIDNo". I need a way to auto-populate this field, based on the already existing Recipient field. Is this possible?
Why I just don't modify the recipient field on our payment form to be bound to the user ID number, there are two reasons.
(1) The field is linked to too many other reports and queries at this point. I believe it could cause an enormous amount of work to modify. (2) the form likes to display whatever it is bound to. There may be a workaround for this, but I'm not aware of it and don't want the form displaying a number instead of a recipient name.
I have a table called Neutron2015. I want the current date and time to complete when entries are made in two other fields. So I am looking for this date and time to populate in EXLStart when an entry is made in Processed By, and also the current date and time to appear in EXLEnd when an entry is made in Completed By with the bold word being the field names.
I have 2 tables, one is like a main table, containing all of the main data, such as a Job Number, Customer, Quantity, etc. I have a second, related, table that acts a breakdown of information. There may be several related records to one main record, it entirely depends on the nature of the job.
What I'd like to do is run a function that looks at a main record, checks if all the related records COMPLETED field is ticked and then tick a field in the main record. I only want it to do this for records where all of the related records are COMPLETED.
I am trying to provide a visual highlight for users of a multi tabbed form. I do a check as users go from tab and tab and i.e. on exit event and I would like to highlight all mandatory fields that have been left incomplete.
I did a test with one control and it worked as expected with the after update event of the specific control.
I then altered the code to add another control, but it does not work as expected. It only highlights one control and not the other. I just recently started using vba, I adapt the code to fit multiple controls and make it work as expected.
Private Sub Ctl2_frm_tab1_Exit(Cancel As Integer) If (Len(Form_2.cmb_arName& "") = 0 Or IsNull(Form_2.cmb_arName)) Or _ (Len(Form_2.cmb_val & "") = 0 Or IsNull(Form_2.cmb_val)) Then Cancel = True MsgBox "Please complete the highlighted control", vbCritical + vbOKOnly
I have a form that a user fills out and the record is not uploaded to the database until the user hits the submit button. In other words, if the user closes the form without saving, the record is not inserted.
My end goal is to have the user click the button and have 3 things happen:
1) Record inserted into the database 2) A PDF of the record is saved to a per-identified directory 3) An outlook new message window opens with recipients pre-entered and the newly created PDF included as an attachment.
I can achieve steps 1 and 2 no problem. However, the way I get the PDF is by having the VBA simply print and the user selects the Adobe PDF. This does not let the VBA dictate the directory (or file name) and then makes me completely stumped for step 3.
I have a primary school database. I'm trying to create a form that allows a teacher to select their class, then select a subject and then be presented with a data entry form in a table layout that lists only their student's names in one column and an empty column to input results for the selected subject.
To simplify my explanation to just three tables, lets say my tables are: > Students....which stores student names plus a foreign key for their class > Classes...which stores the class name > Results...which stores all the results (fields are: ResultID (key), StudentID, SubjectID, Result, DateofResult)
I have no problems creating reports where the teacher selects their class from a combo box to generate a report based on a crosstab query. But this one has me stumped.
I have two linked tables (uneditable). They are linked by PersonID and they also have email address in common. For sake of example let's say one table has names of people, and the other table has the address they live at.
I have a user who requires a "datasheet" view of certain columns from each table. No problem, can do that easily in a query.
The issue is that he also wants to have an editable column that would have say "Address Confirmed". Clearly I need another table. If I make a three table query I find no way to edit that new column.
I have two tables, one table (1) hold three fields, one of those fields is the master key (index). The other table (2) has a field which I want to lookup from table 1, that part is working. In the combo box I get all three fields displayed as I make my selection. I want to copy the other two fields as text at the time the lookup index is selected. I do not what the fields to automatically update each time the table is displayed. I have looked at update macros, I've looked at VBA.
I am trying to run a simple update query to copy data from one column (Addrl1)to another column (Working_Addrl1) within the same file and I can't for the life of me figure it out. Then I need to repeat for addrl2 and addrl3 to working_addrl2 and working_addrl3.
I have a data base with names, email IDs, phone numbers of 5 types(example quality, security, IT,finance etc) of person from ten different project teams. I created a basic form for the end user to enter values and created fields for each of the person's name, email ID etc based on the personal type( liek quality, IT, finance etc) on each team. The background table contains records of almost 200 people now.
All of these people will be trained for one task and some will be trained for multiple tasks. I know how to make the combo box allow multiple values/selections but, i cannot list out all 200 personal names in the combobox's rowsource/value list. Is it possible to combine all different name fields and list out all personal(of one team), so that the end user can just select multiple names for that team who have been trained and so on. i need to set the rowsource of the combobox to the values of all personal from one team so the team leader can just go select who has been trained and who has not.
DoCmd.RunSQL (" update tbl_userinformation SET [05-Henrichpiramid] = Yes where Username= Text146.value AND actualdate=Text148.value ;") DoCmd.RunSQL (" update tbl_userinformation SET [combination] = [05-Henrichpiramid] where Username= Text146.value AND actualdate=Text148.value ;")
i want to update the column combination to its last value with concatanation to the value of current column.
I've split my database into a front end and back end which was relatively easy. I did this so that multiple users can have their own front end. But if I have to go in and change the back end and front end, does that mean I have to remake all the front ends? Right now I'm finding that if I delete my linked tables on the front end and then import them into the back end again and change everything on one screen and then split it again is the only option I know of.
how to Add/Update record including existence of record based on single unique field.Now I trying to learn how to check existence of record on multiple field before adding (at least two) and how to update the record with multiple field record
Below is my testing table fields
Year Month Working Days 2013 Jan 20 2013 Feb 17 2013 Mar 22
Now two situations adding a new record and updating the existing record Which means the unique fields are (Year + Month)
I would like to update the Previous Education tab based on values on the Courses tab.The aim of this is to keep a clients previous education upto date in order to append it to a CV etc.
In this table I have two fields Seats Available and Seats Remaining
When I register a student to a Course in the Courses table I would like the corresponding Seats Remaining field for that course to decrease automatically.
I can, of course, run a report or a query to see how many are enrolled in the course and then manually update the Seats Remaining field (which is what I currently do), but I would like this process to be automated each time I register a new student.