Please help -- A form with two tabs

B

Blinda

Hi all,

I have a form with 2 tabs, two fields ID and Visit#, which are from the same
table, need to be seen in these two tabs. When I entered the ID and Visit#
for the first tab, I hope it will automatically show to the second tab.

When I finished enter the first tab, close the form, and then open the form
again and get into the second tab, then the ID and visit# are shown there. If
I do not close the form and get into the second tab directly, the ID and
Visit# will not be shown. It also will not let me enter the same ID and
Visit# into the second tab, a warning says, "a duplicate record is created to
that table".

It is a noise. Please advise for a solution.

Thank you,

Blinda
 
O

Ofer

Why do you put this fields in the Tab control?
If they are from the same table, then display them in the Form header
instead, that way they will be displayed in both tabs
 
B

Blinda

Thank you for your reply. If I had to put them in two tabs, do you have a way
to do it?

Thanks,

Blibda
 
V

Van T. Dinh

My guess is that you have a Subform on one of the Tab page or even 2
different Subforms on 2 different tab pages.

Perhaps, you need to describe in more detail of your set-up before accurate
suggestion can be offered. You need to describe the main Form, e.g. its
RecordSource and Controls on the main Form and the Subform(s) and how you
link the data on the main Form to the Subform(s), e.g. the LinkMasterFields
and LinkChildFields.
 
B

Blinda

Thank you for your reply.

The structure of the form is: The main form includes several tabs (these two
tabs are in them). Inside the two tabs I have problem with, there is a
subform for each of the tab. Can you figure out how it looks like?

Thank you again,

Blinda
 
O

Ofer

Just as Van T. Dinh said, we need more information, it sound like you have
two subforms on the main form, that are bounded to the same table, and they
both used for data input.
It just doesn't sound like something you would do, especially to avoid
duplicates

In any case, on the Before Update event of the fields where you enter the
key, in the subform, run the code that check if the data already exist

If DCount("*","TableName","[visit#]= " & Me.[visit#] & " And ID = " &
Me.ID)>0 Then
Msgbox "Record Exist"
Cancel = True
End If
 
B

Blinda

Yes, you are right. The main form included two tabs. which are two forms. The
two
forms are used for data input. But I can/need not input ID and Visit# for
the 2nd tab (which is a subform) since the ID and visit# are from the same
table just data input on the 1st tab (which is a subform too). Inside each of
the tab, I have another subform.

If I use the following code to check, it is always showing the message
"Record Exist", which is true. Because I will data entry on the 1st tab
first, and the record already in the table used for two tabs.

Please help what else I can try. Thank you.
Ofer said:
Just as Van T. Dinh said, we need more information, it sound like you have
two subforms on the main form, that are bounded to the same table, and they
both used for data input.
It just doesn't sound like something you would do, especially to avoid
duplicates

In any case, on the Before Update event of the fields where you enter the
key, in the subform, run the code that check if the data already exist

If DCount("*","TableName","[visit#]= " & Me.[visit#] & " And ID = " &
Me.ID)>0 Then
Msgbox "Record Exist"
Cancel = True
End If


Blinda said:
Thank you for your reply. If I had to put them in two tabs, do you have a way
to do it?

Thanks,

Blibda
 
J

John Vinson

Yes, you are right. The main form included two tabs. which are two forms. The
two
forms are used for data input. But I can/need not input ID and Visit# for
the 2nd tab (which is a subform) since the ID and visit# are from the same
table just data input on the 1st tab (which is a subform too). Inside each of
the tab, I have another subform.

If I use the following code to check, it is always showing the message
"Record Exist", which is true. Because I will data entry on the 1st tab
first, and the record already in the table used for two tabs.

If the two tab pages have two DIFFERENT subforms based on the SAME
table, you are indeed going to have trouble!

Perhaps you could put the Tab Control on the Subform, not on the
mainform; put some controls on the first page, other controls on the
second page.

You still haven't said what is the Recordsource for the mainform or
the subforms. This would help us considerably.

John W. Vinson[MVP]
 
B

Blinda

John,

Thank you for your help. I have solved my problem by putting them into the
same from, not into two subforms.

Happy Holidays to all of you!

Blinda
 
Top