When you open the secord form:
Docmd.OpenForm "SecondForm", , , , , ,Me.txtMedicalRec
In the line above, txtMedicalRec would be the medical record number
that is on the first form that you want to use on the second form.
Now in the Open event of the second form:
If Not IsNull(Me.OpenArgs) Then
Me.Filter = "[MedicalRecordNumber] = '" & Me.OpenArgs & "'"
Me.FilterOn = True
If Me.Recordset.RecordCount = 0 Then
DoCmd.GoToRecord , , acNewRec
Me.txtMedicalRecord = Me.OpenArgs
End If
End If
In the code above, [MedicalRecordNumber] would be the field in the
form's record source that has the medical record number.
txtMedicalRecordNumber would be the control on the form that is bound
the the medical record number field.
Ramtin said:
I am quite amateur, please explain how I can create such an
argument that populates every new records on medical record # field
on further forms. I have 7 forms and I want user enters the value on
the first form and then it automatically goes to further forms
:
I don't really understand your aversion to sub forms, but you have
two issues to deal with. One is selecting a medical record number
that already exists in the other tables so that the related records
are presented. The other is when a new medical record has been
entered in the first table, but has no records in the related
tables.
I would suggest you use the OpenArgs argument of the OpenForm
method in the first form to pass the value of the current medical
record number to the form you are opening. Then in the Load event
of the opened form, set the form's filter to that value. Check to
see if the form's recordset has any records. If it does not, that
means this is a new record. Then goto a new record and populate
the medical record number control on the form.
:
I have already created the command buttons to oprn my next from
but what I can not do is populating a value which is similar on
all forms. I mean I have a field which is similar on all
tables/forms. I just want that user input the value on the first
form and then it automatically goes the all further forms, no need
to reenter it on every form
:
If you don't want a main form/subform arrangement, you can have a
command button that opens the related form. If you used the form
wizard, it will even offer you this choice.
After you select your main form and fields in step 2 of the
wizard, just select your second table (and its fields), before
hitting next - the wizard will offer you a choice of
mainform/subform or a command button.
--
Joan Wild
Microsoft Access MVP
Ramtin wrote:
I do not want to have form and subform to be displayed at the
same time, that's why I am trying to link my table/form to each
other, as you told I linked medical record field on main table
to all other tables with same field but still now I can not
populate the value of medical record number on all of my
tables/forms
Please help, I am sick of it