Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Link data between forms

Status
Not open for further replies.

ttiot10

Programmer
Aug 28, 2003
3
US
Hi,
I have two forms (two different tables)that I want to link. One is for record creation,(frmActionPlan), and the other (frmOccurrence), is a reference only to the Occurrence that the Action plan is being created for. They share a common field called "OccurrenceID" (primary key in OccurrenceTBL). I want to populate the first form (frmActionPlan) with only the OccurrenceID field (selected from a list of occurrences)and then have a separate window (frmOccurenceDetail), remain open and display the detail of the OccurrenceTBL based on the OccurrenceID in (frmActionPlan). The data in the (frmOccurrence) form should change appropriately when the record is changed on frmActionPlan using the navigation buttons.


Scenero:
Open frmActionPlan and click cmdSelectOccur,

which opens frmselectOccur, then

select Occurrence from DataGrid, which reopens frmActionPlan, and creates new ActionPlan.

Datagrid populates "OccurrenceID" field in new ActionPlan and Opens frmOccurrenceDetail

frmOccurrenceDetail displays the detail of the Occurrence based on the OccurrenceID in frmActionPlan.

I have code for most of the actions here, but it is really long. I will post if you want it. All I need to know is how to make the content of frmOccurrenceDetail reflect the proper information based on whatever OccurrenceID field is in the frmActionPlan.

I am a new programmer and I know this is probably a stupid question, sorry.
 
In the valid_Method of the field you will change the OccurrenceID you can modify a SQL for the second Form.

frmActionPlan.YourObject.recordset = "YourNewSql"
frmActionPlan.YourObject.refresh

It is very teoreticly because we don't know how source both form-Datagrids

peterguhl@yahoo.de
 
Hi Poltergeist,

Thanks for responding. I knew I should have put the code. Sorry. Here it is. Does this help to explain what I am trying to do?

Thanks again for your help.

---------------------------------------------------------------------
frmActionPlan calls frmOccurSel form

---------------------------------------------------------------------
Private Sub cmdSelOccur_Click()
frmSelOccur.Show
End Sub

---------------------------------------------------------------------
frmSelOccur - select occurrence and return to action plan
---------------------------------------------------------------------

Option Explicit


' declares the field that will be sent to actionplan form
Public myField1


Private Sub FGOccur_Click()
FGOccur.Col = 0
myField1 = FGOccur.Text 'collect first column of datagrid, place in variable

Dim Msg, Style, Title, Response 'MsgBox to verify user picked correct Occurrence from datagrid

Msg = "Is the correct occurrence selected ?" ' Define message.
Style = vbYesNo + vbQuestion + vbDefaultButton2 ' Define buttons.
Title = "Confirm Occurrence Selection" ' Define title.
Response = MsgBox(Msg, Style, Title)

If Response = vbYes Then ' Record selected correctly, go back to Action Plan form

On Error Resume Next
frmActionPlan.Show ' Open the ActionPlan
deCQISelect.rsActionPlans.AddNew 'Create a new Action Plan
frmActionPlan.txtOccurRef.Text = frmSelOccur.myField1 'Insert the OccurrenceID, from variable FGOccur
frmOccurSum.Show 'Open the reference form to display occurrence data

frmActionPlan.Refresh 'Refresh the action plan form
Unload Me 'close this form.
Else ' Go back and select another.

Exit Sub ' Exit Sub routine without selecting record
End If

End Sub

--------------------------------------------------------------------
FrmOccurrenceDetail contains only the bound controls
that bind it to it's table in the database.
--------------------------------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top