A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Add new records into source table on Form



 
 
Thread Tools Display Modes
  #1  
Old February 9th, 2010, 05:44 PM posted to microsoft.public.access.forms
Frank[_26_]
external usenet poster
 
Posts: 13
Default 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
Ads
  #2  
Old February 9th, 2010, 07:26 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default 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  
Old February 10th, 2010, 12:20 AM posted to microsoft.public.access.forms
Frank[_26_]
external usenet poster
 
Posts: 13
Default 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  
Old February 10th, 2010, 12:28 AM posted to microsoft.public.access.forms
Frank[_26_]
external usenet poster
 
Posts: 13
Default 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  
Old February 10th, 2010, 03:38 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default 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  
Old February 10th, 2010, 04:04 PM posted to microsoft.public.access.forms
Frank[_26_]
external usenet poster
 
Posts: 13
Default 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  
Old February 10th, 2010, 08:05 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default 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  
Old February 10th, 2010, 10:45 PM posted to microsoft.public.access.forms
Frank[_26_]
external usenet poster
 
Posts: 13
Default 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  
Old February 11th, 2010, 02:29 PM posted to microsoft.public.access.forms
Daryl S[_2_]
external usenet poster
 
Posts: 881
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:32 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright 2004-2018 OfficeFrustration.
The comments are property of their posters.