View Full Version : Problems with recording data in table through forms


Mumus
07-05-2006, 06:13 AM
Hi All,

This is my first post on this forum...:)

I'm having the following problems:

I have a table with "n" fields.
Each field will constitute a form.
Each form will have a button which will open the next form.
Basically I want to record new data into the table (database) through FORMS.
What I am unable to do is to record data on the same line in the table !!!
What I have so far is that I am able to move to the next record when creating a new NCR but the rest of the data (fields) are going to overwright the first record in the table (first line).

I would attach my database here but the file size is bigger that permitted.
If someone interested I could foward it on e-mail.

My second issue is that after recording data into the table I want to be able to modify that data through a form. When a certain NCR number is choosed this will pop-up the NCR form with all fields from the table.


Any suggestions are more than welcomed.

Thanks for your help...

Mumus.

jenp
12-09-2006, 01:08 AM
You just need to make sure your second (etc) form knows which field to put the info into... you can do this by making sure each record has a primary key that is represented on the form - either hidden or not - and then linking them in the event called by the button. The VB code could look like:


Private Sub open_field_2_form_Click()
On Error GoTo Err_open_field_2_form_Click

Dim stDocName As String
Dim stLinkCriteria As String

// change stDocName to the name of the form you want the button to open
stDocName = "field_2_form"

// [ID] should be whatever your autonumber field is called in the table - this
// really should be an autonumber and not a user-modified field.
// Me![ID] references the ID field on the current form
stLinkCriteria = "[ID]=" & Me![ID]

// close the current form
DoCmd.Close

// open the next form making sure the link criterion is met
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_open_field_2_form_Click:
Exit Sub

Err_open_field_2_form_Click:
MsgBox Err.Description
Resume Exit_open_field_2_form_Click

End Sub


Being able to put the data on the correct line *should* fix your second problem, too... unless I'm misunderstanding it. :)

Hope this helps! :)

neileg
12-11-2006, 02:36 AM
Why do you need a new form for each field? I would expect to see all the fields on the same form.