If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Add new records into source table on Form
I created a form for training records. The data source is table
TRAINING. The form has Combo box that is used to select employee. When the employee is selected, the employee's data, such as employee_id, manager, phone, training_course display in the form. This part of the form works well. There was new request from my client. It's requsted that when the training_course displayed on the form is changed, the record with new training_course can be added into source table TRAINING. So, I created "Add" buttorn on the form and used append query method to add the records into the TRAINING table. However, it did not work as I expected. Using append query method, all records of the emplyee in the source table were added into the same (the table has dupcate records), which is not I wanted. I just want to add the new record of the employee (the record shown on the form) to be added into the table. I am not expert on Access. I appreciate any of the help on the issue. Thanks Frank |
#2
|
|||
|
|||
Add new records into source table on Form
Frank -
You probably need some criteria in your append query to only append the 'current' record on the form. You can do this in query design by using the build button when you are in the criteria row for the training course field. You can test it if the form is open by switching to datasheet mode in the query to see what would be added. -- Daryl S "Frank" wrote: I created a form for training records. The data source is table TRAINING. The form has Combo box that is used to select employee. When the employee is selected, the employee's data, such as employee_id, manager, phone, training_course display in the form. This part of the form works well. There was new request from my client. It's requsted that when the training_course displayed on the form is changed, the record with new training_course can be added into source table TRAINING. So, I created "Add" buttorn on the form and used append query method to add the records into the TRAINING table. However, it did not work as I expected. Using append query method, all records of the emplyee in the source table were added into the same (the table has dupcate records), which is not I wanted. I just want to add the new record of the employee (the record shown on the form) to be added into the table. I am not expert on Access. I appreciate any of the help on the issue. Thanks Frank . |
#3
|
|||
|
|||
Add new records into source table on Form
On Feb 9, 11:26*am, Daryl S wrote:
Frank - You probably need some criteria in your append query to only append the 'current' record on the form. * You can do this in query design by using the build button when you are in the criteria row for the training course field. * You can test it if the form is open by switching to datasheet mode in the query to see what would be added. -- Daryl S "Frank" wrote: I created a form for training records. The data source is table TRAINING. The form has Combo box that is used to select employee. When the employee is selected, the employee's data, such as employee_id, manager, phone, training_course display in the form. *This part of the form works well. There was new request from my client. It's requsted that when the training_course displayed on the form is changed, *the record with new training_course can be added into source table TRAINING. So, I created "Add" buttorn on the form and used append query method to add the records into the TRAINING table. However, it did not work as I expected. Using append query method, all records of the emplyee in the source table were added into the same (the table has dupcate records), which is not I wanted. I just want to add the new record of the employee (the record shown on the form) to be added into the table. I am not expert on Access. I appreciate any of the help on the issue. Thanks Frank .- Hide quoted text - - Show quoted text - Daryl, I added criteria in my append query. I built 2 criteria: 1 [Forms]! trainingForm]!employee_id] = training.employee_id. 2. Forms]! trainingForm]!course_name] training.course_name. After I applied these criteria in the query, no row was appended into the table. However, If I took out criteria 2. all records with the employee_id were append into the table. Any idea? Thanks Frank |
#4
|
|||
|
|||
Add new records into source table on Form
On Feb 9, 4:20*pm, Frank wrote:
On Feb 9, 11:26*am, Daryl S wrote: Frank - You probably need some criteria in your append query to only append the 'current' record on the form. * You can do this in query design by using the build button when you are in the criteria row for the training course field. * You can test it if the form is open by switching to datasheet mode in the query to see what would be added. -- Daryl S "Frank" wrote: I created a form for training records. The data source is table TRAINING. The form has Combo box that is used to select employee. When the employee is selected, the employee's data, such as employee_id, manager, phone, training_course display in the form. *This part of the form works well. There was new request from my client. It's requsted that when the training_course displayed on the form is changed, *the record with new training_course can be added into source table TRAINING. So, I created "Add" buttorn on the form and used append query method to add the records into the TRAINING table. However, it did not work as I expected. Using append query method, all records of the emplyee in the source table were added into the same (the table has dupcate records), which is not I wanted. I just want to add the new record of the employee (the record shown on the form) to be added into the table. I am not expert on Access. I appreciate any of the help on the issue. Thanks Frank .- Hide quoted text - - Show quoted text - Daryl, I added criteria in my append query. I built 2 criteria: 1 [Forms]! trainingForm]!employee_id] = training.employee_id. 2. Forms]! trainingForm]!course_name] training.course_name. After I applied these criteria in the query, no row was appended *into the table. However, If I took out criteria 2. all records with the employee_id were append into the table. Any idea? Thanks Frank- Hide quoted text - - Show quoted text - In addition, I used method of Insert record (see my code below). It can update the reord, but can not add (insert) record. I don't know why. Frank Private Sub Add_New_Record_Click() On Error GoTo Err_Add_New_Record_Click DoCmd.GoToRecord , , acNewRec CurrentDb.Execute "INSERT INTO training (EMPLOYEE,Training_program_name, Training_date, Training_results, manager, NUID,comments) Values('" & EMPLOYEE.Value & "', '" & Training_program_name.Value & "', '" & Training_date.Value & "', '" & Training_results.Value & "', '" & Manager.Value & "', '" & NUID.Value & "', '" & Comments.Value & "' )" Exit_Add_New_Record_Click: Exit Sub |
#5
|
|||
|
|||
Add new records into source table on Form
Frank -
What is the primary key on your TRAINING table? Any other Unique Keys? These can prevent records from being added if the unique key already exists. Also, for your query, you want the second criteria to be EQUAL TO the new courst_name: Forms![trainingForm]![course_name] = training.course_name -- Daryl S "Frank" wrote: On Feb 9, 4:20 pm, Frank wrote: On Feb 9, 11:26 am, Daryl S wrote: Frank - You probably need some criteria in your append query to only append the 'current' record on the form. You can do this in query design by using the build button when you are in the criteria row for the training course field. You can test it if the form is open by switching to datasheet mode in the query to see what would be added. -- Daryl S "Frank" wrote: I created a form for training records. The data source is table TRAINING. The form has Combo box that is used to select employee. When the employee is selected, the employee's data, such as employee_id, manager, phone, training_course display in the form. This part of the form works well. There was new request from my client. It's requsted that when the training_course displayed on the form is changed, the record with new training_course can be added into source table TRAINING. So, I created "Add" buttorn on the form and used append query method to add the records into the TRAINING table. However, it did not work as I expected. Using append query method, all records of the emplyee in the source table were added into the same (the table has dupcate records), which is not I wanted. I just want to add the new record of the employee (the record shown on the form) to be added into the table. I am not expert on Access. I appreciate any of the help on the issue. Thanks Frank .- Hide quoted text - - Show quoted text - Daryl, I added criteria in my append query. I built 2 criteria: 1 [Forms]! trainingForm]!employee_id] = training.employee_id. 2. Forms]! trainingForm]!course_name] training.course_name. After I applied these criteria in the query, no row was appended into the table. However, If I took out criteria 2. all records with the employee_id were append into the table. Any idea? Thanks Frank- Hide quoted text - - Show quoted text - In addition, I used method of Insert record (see my code below). It can update the reord, but can not add (insert) record. I don't know why. Frank Private Sub Add_New_Record_Click() On Error GoTo Err_Add_New_Record_Click DoCmd.GoToRecord , , acNewRec CurrentDb.Execute "INSERT INTO training (EMPLOYEE,Training_program_name, Training_date, Training_results, manager, NUID,comments) Values('" & EMPLOYEE.Value & "', '" & Training_program_name.Value & "', '" & Training_date.Value & "', '" & Training_results.Value & "', '" & Manager.Value & "', '" & NUID.Value & "', '" & Comments.Value & "' )" Exit_Add_New_Record_Click: Exit Sub . |
#6
|
|||
|
|||
Add new records into source table on Form
On Feb 10, 7:38*am, Daryl S wrote:
Frank - What is the primary key on your TRAINING table? *Any other Unique Keys? * These can prevent records from being added if the unique key already exists. Also, for your query, you want the second criteria to be EQUAL TO the new courst_name: * *Forms![trainingForm]![course_name] = training.course_name -- Daryl S "Frank" wrote: On Feb 9, 4:20 pm, Frank wrote: On Feb 9, 11:26 am, Daryl S wrote: Frank - You probably need some criteria in your append query to only append the 'current' record on the form. * You can do this in query design by using the build button when you are in the criteria row for the training course field. * You can test it if the form is open by switching to datasheet mode in the query to see what would be added. -- Daryl S "Frank" wrote: I created a form for training records. The data source is table TRAINING. The form has Combo box that is used to select employee. When the employee is selected, the employee's data, such as employee_id, manager, phone, training_course display in the form. *This part of the form works well. There was new request from my client. It's requsted that when the training_course displayed on the form is changed, *the record with new training_course can be added into source table TRAINING. So, I created "Add" buttorn on the form and used append query method to add the records into the TRAINING table. However, it did not work as I expected. Using append query method, all records of the emplyee in the source table were added into the same (the table has dupcate records), which is not I wanted. I just want to add the new record of the employee (the record shown on the form) to be added into the table. I am not expert on Access. I appreciate any of the help on the issue. Thanks Frank .- Hide quoted text - - Show quoted text - Daryl, I added criteria in my append query. I built 2 criteria: 1 [Forms]! trainingForm]!employee_id] = training.employee_id. 2. Forms]! trainingForm]!course_name] training.course_name. After I applied these criteria in the query, no row was appended *into the table. However, If I took out criteria 2. all records with the employee_id were append into the table. Any idea? Thanks Frank- Hide quoted text - - Show quoted text - In addition, I used method of Insert record (see my code below). It can update the reord, but can not add (insert) record. I don't know why. Frank Private Sub Add_New_Record_Click() On Error GoTo Err_Add_New_Record_Click * * DoCmd.GoToRecord , , acNewRec CurrentDb.Execute "INSERT INTO training (EMPLOYEE,Training_program_name, Training_date, Training_results, manager, NUID,comments) Values('" & EMPLOYEE.Value & "', '" & Training_program_name.Value & "', '" & Training_date.Value & "', '" & Training_results.Value & "', '" & Manager.Value & "', '" & NUID.Value & "', '" & Comments.Value & "' )" Exit_Add_New_Record_Click: * * Exit Sub .- Hide quoted text - - Show quoted text - Daryl, TAINING table does not have primary key and other unique keys. It can have multipe records for employee_id. I do know why the second criterial should be EQUAL TO instead of . Thanks Frank |
#7
|
|||
|
|||
Add new records into source table on Form
Frank -
You want to add the new Training record that is on the form - the one with the new training course - you don't want to insert records for all the other training courses (they already are in the table). -- Daryl S "Frank" wrote: Daryl, TAINING table does not have primary key and other unique keys. It can have multipe records for employee_id. I do know why the second criterial should be EQUAL TO instead of . Thanks Frank . |
#8
|
|||
|
|||
Add new records into source table on Form
On Feb 10, 12:05*pm, Daryl S wrote:
Frank - You want to add the new Training record that is on the form - the one with the new training course - you don't want to insert records for all the other training courses (they already are in the table). -- Daryl S "Frank" wrote: Daryl, TAINING table does not have primary key and other unique keys. It can have multipe records for employee_id. I do know why the second criterial should be EQUAL TO instead of . Thanks Frank .- Hide quoted text - - Show quoted text - Yes, It's correct. When I used "" in criterial, not record can add to the table becouase there is no such record in the table . When I used "=", all data for the employee were added into the table. It seems the append query won't work at all. is there any other way to add (insert) record on the form into the source table. Thanks Frank |
#9
|
|||
|
|||
Add new records into source table on Form
Frank -
Yes. The normal way to add new records is to use the form. You can use the navigation buttons at the bottom (go the * record) and start entering data. It will be saved automatically. If you don't need to see the existing records, you can set the form property Data Entry to Yes, and it will come up with a blank new record to be filled out (same form, different uses). -- Daryl S "Frank" wrote: On Feb 10, 12:05 pm, Daryl S wrote: Frank - You want to add the new Training record that is on the form - the one with the new training course - you don't want to insert records for all the other training courses (they already are in the table). -- Daryl S "Frank" wrote: Daryl, TAINING table does not have primary key and other unique keys. It can have multipe records for employee_id. I do know why the second criterial should be EQUAL TO instead of . Thanks Frank .- Hide quoted text - - Show quoted text - Yes, It's correct. When I used "" in criterial, not record can add to the table becouase there is no such record in the table . When I used "=", all data for the employee were added into the table. It seems the append query won't work at all. is there any other way to add (insert) record on the form into the source table. Thanks Frank . |
Thread Tools | |
Display Modes | |
|
|