ok le me explain......its a survey
there are 17 tables
each with a corresponding form
each table/form represents a dif section of the survey.
so each entire survey has 1 ID#.
so u fill out 17 forms in a row, ur doen the survey.....all those 17 forms
were say ID #1...when u start a new survey i want ID to automatically start
at 2(the next unused ID)
I'm sorry, but I still think your table design IS SIMPLY INCORRECT.
A Survey with 17 sections should have *one* table, with *one* form.
That table would have a field indicating which section this question
belongs to. I'd see the following tables:
Questions
QuestionNo <integer question number>
Section <1 to 17>
Question <text>
Surveys
SurveyID <autonumber perhaps>
<who filled out the survey, when, etc.>
Answers
SurveyID <long integer link to Surveys>
QuestionNo <link to Questions>
Answer
It's pretty clear that you're storing data (section numbers) in table
names and probably also storing data (questions) in field names. This
may make for a bit less work entering data in the short run but it
will make getting the data out MUCH more difficult, and will become an
absolute nightmare if there are any changes made to the survey in the
future.
HOWEVER...
to answer your question, since you may be stuck with this *very bad*
design...
you'll need to explicitly pass the ID from the first form (where it
might be an Autonumber) to each subsequent form. This can be done in
two ways:
- Put sixteen Subforms on separate tab pages of a Tab Control on the
form for the first survey, and use the SurveyID as the master/child
link field
- or, if you really want seventeen standalone forms, "push" the ID
into the form by passing its value in the Form's OpenArgs parameter,
and using the Form's Open event to set the value:
DoCmd.OpenForm "formname", OpenArgs := Me!txtID
and then in each Form's Open event
Private Sub Form_Open(Cancel as Integer)
If Me.OpenArgs & "" <> "" Then
Me!txtID = Me.OpenArgs
End If
End Sub
John W. Vinson[MVP]
John W. Vinson[MVP]