Problem adding records to table

TheStriker

Registered User.
Local time
Today, 21:36
Joined
Jan 5, 2004
Messages
17
Hello,

I have a problem adding a record using my current method. I have a main form with a subform. The subform consist of a listbox(single selection) and its coresponding text boxes. When the user selects a record from the listbox, its text fields reflect the record selected. I've accomplished this using this method because I think this is the only way to get the listbox and its fields on the subform to update when the user selects a record from the listbox:

Forms![New]![Comments_WSReplacement subform]![nSiteID].Value = Me.WSRList.Column(0)
Forms![New]![Comments_WSReplacement subform]![sComment].Value = Me.WSRList.Column(10)
Forms![New]![Comments_WSReplacement subform]![nContactTypeID].Value = Me.WSRList.Column(4)
Forms![New]![Comments_WSReplacement subform]![nActionTypeID].Value = Me.WSRList.Column(8)
Forms![New]![Comments_WSReplacement subform]![nIssueTypeID].Value = Me.WSRList.Column(6)
Forms![New]![Comments_WSReplacement subform]![dtCreatedON].Value = Me.WSRList.Column(1)

This works fine but when I try to add a record using the DoCmd.GoToRecord,,acNewRec, it actually edits the record selected in the listbox. When I click to add a new record here are the arguments:

DoCmd.GoToRecord , , acNewRec

Me.nSiteID.Value = Forms!New!nSiteID
Me.nUserID.Value = Forms!New!UserID
Me.dtCreatedON.Value = Now()

Is there a more reliable way to do this? Thanks in advance.
 
We use a main form with a listbox to view data. The users use the filters at the top to pull only the info they want to look at. Then we use Command Buttons based on the record selected in the list box to go to another form to edit the record or to add a new record.

To Add a record you may need the Primary Key fields to be filled out in a field(s) on the main form before going over to the Edit/Add Form. Depends on your data structure.

hope this helps
 

Users who are viewing this thread

Back
Top Bottom