GoToRecord..... acNewRec

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

new to this so don't be to hard on me...

I'm want to add a new record to a table that is used in a query that my form
uses.

how do I tell it to add a record to that specific table and does it
automaticaly know what data from the query to add?

The query uses several tables.

Thanks
 
If you want to add data to a particular table, you should have a form that is
based on just that table.
 
There are two boxes on the Form.

In the meetings table it only keeps track of the meetings. In the second
table it keeps track of the Employee and a key pointing (it uses Meeting #)
to each meeting that employee has had.

The first is a list box that uses a query that reads the Employee/Key table
and the Meetings table and shows a list of meetings that employee has had.

What happens is there is a combo box that contains a list of "Meetings".
The end user will select a meeting and what I want to do is to add to a to
the Employee/Key table the "Employee" and the Key field that points to the
"Meetings" table.

Right now here is the code....

DoCmd.GoToRecord acDataTable, , acNewRec

Make better sense and can this be done? Do I speicify the table name and the
fields to add to the table?
 
There is no difference in addin a new record to a table when the form's
record source is a query, provided that query is based on the table. When
you go to a new record, you populate the controls, and it is added.
 
Sounds to me like you should have 3 tables. tblEmployees, tblMeetings and
tblEmployeeMeetings.

tblEmployees - EmployeeID, EmployeeName and so on...
tblMeetings - MeetingID, MeetingDescription and so on...
tblEmployeeMeetings - EmployeeID, MeetingID

Your form should be on tblEmployeeMeetings. The form could contain two
combos, on with a list of employees, the other with a list of meetings.

This table will store all the meetings an employee has had and will also
hold information representing all the employees that attended a meeting.
 
can you come visit me??? wouldn't that be nice. I do have all three tables
essentially how you said. The form was using two of the databases. not
really sure why I did it that way. I'm working on what youv'e explained to
me. I've already changed the form so that it only uses the EmpMeetings.

I'll let you know how it turns out!
 
Hi Denise,
I would do in this way:

Make the employee combo box with two columns, the first (masked) containing
the EmployeeID and the second (visible) EmployeeName, so the combo will
display the name but contain the id.
Create a continous form with as recordsource tblEmployeeMeetings. Create in
this form a combo with the meetings. Create this combo as above (i.e. two
columns MeetingID, MeetingDescription ) and put as control source
tblEmployeeMeetings.MeetingID.
Incorporate this form in the first one and use as link master field the name
of the employees combo and as link child field EmployeeID.
Now the trick is done. When you choose an employee in the main form the
subform will shows all the meetings for this employee and if you add a new
meeting in the star row(the last one in the subform) it will be automatically
be bound to this employee.

HTH Paolo
 
Ok... it still isn't working.. this is a subform that i am having problems
with. the form is based off of the Emp/Meetings table


When I click on the Add New Record button it still isn't working.

DoCmd.GoToRecord , , acNewRec

this is the correct command isn't it?
 
The statement is correct. Is your button on the subform? If is not you have
first to set focus on the subform.

Forms![your main form name]![your subform name].SetFocus
DoCmd.GoToRecord , , acNewRec

HTH Paolo
 
I did have the button on the subform.

What I ended up doing was deleting the query and the button. I recreated
all of it and now it works! Not sure why because the old and the new look
identical. But the important thing is it works. Thanks for everyone's help.

Paolo said:
The statement is correct. Is your button on the subform? If is not you have
first to set focus on the subform.

Forms![your main form name]![your subform name].SetFocus
DoCmd.GoToRecord , , acNewRec

HTH Paolo

denise said:
Ok... it still isn't working.. this is a subform that i am having problems
with. the form is based off of the Emp/Meetings table


When I click on the Add New Record button it still isn't working.

DoCmd.GoToRecord , , acNewRec

this is the correct command isn't it?
 
Back
Top