Keeping same value form to form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

Looking for a way to go from form 1 to form 2 and keep the same value in table 1 and table 2. Better explanatio
I table 1 has an customer id field defined as auto increment field Table 2 has the customer id filed as numeric
There is a one - one relationship. There is a button on page one to go to page 2 when we hit that button is does not go to the customer id that was just created in form 1. how do I accomplish that

Thanks

Joe
 
Did you do anything to select a specific record when form 2 is opened? You
did not describe anything you did.

Without a little more information, like what data you have, how it is
structured, what is the RecordSource of the Forms, etc., it's going to be
difficult to give you a specific answer.

In general, if you've just entered a new record, you need to save it and use
its unique id field to open that same record in the second form, perhaps in
the WhereCondition argument of the DoCmd.OpenForm that you use to open it.

If the unique id field is displayed in txtUnique, and frmTwo is the second
Form, and TheKey is the corresponding key field in the Table that is the
Record Source for frmTwo, the code might look something like:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "frmTwo",,,"[TheKey] = " & Me![txtUnique]

That's air code, untested...

Larry Linson
Microsoft Access MVP


Larry Linson
Microsoft Access MVP



Joe said:
Hello,

Looking for a way to go from form 1 to form 2 and keep the same value in
table 1 and table 2. Better explanation
I table 1 has an customer id field defined as auto increment field Table 2
has the customer id filed as numeric.
There is a one - one relationship. There is a button on page one to go to
page 2 when we hit that button is does not go to the customer id that was
just created in form 1. how do I accomplish that?
 
On form1 the button to goto form2 has th following cod
Private Sub Open_Page_3_Click(
On Error GoTo Err_Open_Page_3_Clic
DoCmd.RunCommand acCmdSaveRecor
Dim stDocName As Strin
Dim stLinkCriteria As Strin
Dim strPT_ID As Strin
strPT_ID = Me!PT_I
stDocName = "Page 3
DoCmd.OpenForm stDocName, , , , acFormEdit, , strPT_I
Forms![Page 3]!PT_ID.SetFocu
DoCmd.FindRecord strPT_ID, , True, , True, acAll, Tru

Any advice is appreciate

Jo

----- Larry Linson wrote: ----

Did you do anything to select a specific record when form 2 is opened? Yo
did not describe anything you did

Without a little more information, like what data you have, how it i
structured, what is the RecordSource of the Forms, etc., it's going to b
difficult to give you a specific answer

In general, if you've just entered a new record, you need to save it and us
its unique id field to open that same record in the second form, perhaps i
the WhereCondition argument of the DoCmd.OpenForm that you use to open it

If the unique id field is displayed in txtUnique, and frmTwo is the secon
Form, and TheKey is the corresponding key field in the Table that is th
Record Source for frmTwo, the code might look something like

DoCmd.RunCommand acCmdSaveRecor
DoCmd.OpenForm "frmTwo",,,"[TheKey] = " & Me![txtUnique

That's air code, untested..

Larry Linso
Microsoft Access MV


Larry Linso
Microsoft Access MV



Joe said:
table 1 and table 2. Better explanatio
I table 1 has an customer id field defined as auto increment field Table
has the customer id filed as numeric
There is a one - one relationship. There is a button on page one to go t
page 2 when we hit that button is does not go to the customer id that wa
just created in form 1. how do I accomplish that
 
Joe,

in your post you say that PT_ID is numeric, so why are you passing it as a
string in your OpenArgs? You should use the Where condition instead, as was
pointed out by Larry Linson. Something like:

'assumes that [PT_ID] is the field name in the underlying table

strPT_ID = "[PT_ID]=" & Me!PT_ID
stDocName = "Page 3"
DoCmd.OpenForm stDocName ,,,strPT_ID

Form 2 will open and filter on the corresponding [PT_ID] if it now exists in
the underlying table. The two lines of code following your DoCmd.OpenForm
are completely unnecessary.

HTH,
Jeff


Joe said:
On form1 the button to goto form2 has th following code
Private Sub Open_Page_3_Click()
On Error GoTo Err_Open_Page_3_Click
DoCmd.RunCommand acCmdSaveRecord
Dim stDocName As String
Dim stLinkCriteria As String
Dim strPT_ID As String
strPT_ID = Me!PT_ID
stDocName = "Page 3"
DoCmd.OpenForm stDocName, , , , acFormEdit, , strPT_ID
Forms![Page 3]!PT_ID.SetFocus
DoCmd.FindRecord strPT_ID, , True, , True, acAll, True

Any advice is appreciated

Joe

----- Larry Linson wrote: -----

Did you do anything to select a specific record when form 2 is opened? You
did not describe anything you did.

Without a little more information, like what data you have, how it is
structured, what is the RecordSource of the Forms, etc., it's going to be
difficult to give you a specific answer.

In general, if you've just entered a new record, you need to save it and use
its unique id field to open that same record in the second form, perhaps in
the WhereCondition argument of the DoCmd.OpenForm that you use to open it.

If the unique id field is displayed in txtUnique, and frmTwo is the second
Form, and TheKey is the corresponding key field in the Table that is the
Record Source for frmTwo, the code might look something like:

DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm "frmTwo",,,"[TheKey] = " & Me![txtUnique]

That's air code, untested...

Larry Linson
Microsoft Access MVP


Larry Linson
Microsoft Access MVP



Joe said:
value in
table 1 and table 2. Better explanation
I table 1 has an customer id field defined as auto increment field
Table 2
has the customer id filed as numeric.
There is a one - one relationship. There is a button on page one
to go to
page 2 when we hit that button is does not go to the customer id that was
just created in form 1. how do I accomplish that?
 
Ok so I have added
Private Sub Open_Page_3_Click(
On Error GoTo Err_Open_Page_3_Clic
Dim stDocName As Strin
Dim stLinkCriteria As Strin
Dim strPT_ID As Strin
strPT_ID = "[PT_ID]=" & Me!PT_I
stDocName = "Page 3
DoCmd.OpenForm stDocName, , , strPT_I

It still does not go to that record on page 3. Perhaps it is the way I have the tables structured. Pt_id is an autonumber. The child tables get the PT_id infor via a Lookup query. Select Pt_Id from patient_data

Any help appreciated

Joe
 
Back
Top