UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Trying to link main form to popup.    
 
   
sredworb
post Dec 2 2006, 06:15 AM
Post#1



Posts: 940
Joined: 14-March 05
From: Chicago Suburb


Hello,
Try to explain this as best as I can.
I have a main form with several cmd buttons, (Not interested in subforms for this project) that opens popup forms.
Example: Main form frmPerson, cmd button cmdVehicle, when clicked opens frmVehicle displaying control boxes to be populated by the user. My problem is that I can't figure out how to link this PopUp Form frmVehicle to the main form, frmPerson.
I tried openargs but when I attempt to create a new record, the form is refreshed and the openargs linking is not working.
Any help is greatly appreciated,
Thanks,
Go to the top of the page
 
Alan_G
post Dec 2 2006, 06:57 AM
Post#2


Remembered as Utterly Yorkshire and Forum/Wiki Editor
Posts: 16,533
Joined: 12-January 03
From: Devon UK


Hi
How are vehicles related to people ? Is it that one person can own many vehicles and you want to open a form bound to tblVehicles that will allow you to add a new vehicle to the person currently selected in your frmPerson?
Assuming the above to be the scenario, then in the On Click event of your cmdVehicle button use
Docmd.OpenForm "frmVehicle",,,,acFormAdd,,Me.NameOfYourControlWithPersonID
On your frmVehilce have (hidden if you want) a text box bound to your tblVehicle FK. Now in frmVehicle On Load event, use
If Not IsNull(Me.OpenArgs) Then
Me.NameOfYourFKTextBox = Me.OpenArgs
End If
Now when you save your newly created vehicle record it will be correctly related to the person.........
HTH
Alan
Go to the top of the page
 
Silk
post Dec 2 2006, 07:08 AM
Post#3



Posts: 7
Joined: 21-November 06
From: Manchester, England


Hello,
If you use a wizard on your main form to create a button choose the options:
Form Operation
Open Form
Open the form and find specific data to display
Link your matching key fields
When you've done this open your frmVehicle in design mode and go to the BeforeInsert event
Create an Event Procedure as follows:
Private Sub Form_BeforeInsert (Cancel As Integer)
Me.YourVehicleMatchingKeyField = [Forms]![frmPerson]![YourPersonMatchingKeyField]
End Sub
When you go to a new record you dont have to key your key field in as this will populate it for you.
Hope this helps
Silk
Go to the top of the page
 
sredworb
post Dec 2 2006, 08:46 AM
Post#4



Posts: 940
Joined: 14-March 05
From: Chicago Suburb


Hello,
hese are new suggestions, thanks,
Oreally appreciate it.
Jerry
Go to the top of the page
 
sredworb
post Dec 2 2006, 08:56 AM
Post#5



Posts: 940
Joined: 14-March 05
From: Chicago Suburb


Dear Homer,
sed your suggestion it worked great.
Only problem I had was that while the form is still opened frmVehicle, if I want to add a new record to the same person, the openargs link of fk resets to 0. Isn't there a way to hold that value in that control until the form is closed?
Thanks again,
Jerry
Go to the top of the page
 
vtd
post Dec 2 2006, 03:51 PM
Post#6


Retired Moderator
Posts: 19,667
Joined: 14-July 05



Try changing the assignment statement to:
CODE
Me.NameOfYourFKTextBox.DefaultValue = Me.OpenArgs
Go to the top of the page
 
Alan_G
post Dec 2 2006, 06:02 PM
Post#7


Remembered as Utterly Yorkshire and Forum/Wiki Editor
Posts: 16,533
Joined: 12-January 03
From: Devon UK


Hi
Glad it worked for you, and with Van's solution you should be able to add further records also....
HTH
Alan
Go to the top of the page
 
sredworb
post Dec 2 2006, 09:13 PM
Post#8



Posts: 940
Joined: 14-March 05
From: Chicago Suburb


That did it.
Thanks Gentlemen,
Jerry
Go to the top of the page
 
Alan_G
post Dec 2 2006, 10:08 PM
Post#9


Remembered as Utterly Yorkshire and Forum/Wiki Editor
Posts: 16,533
Joined: 12-January 03
From: Devon UK


Great - continued success sad.gif
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    16th September 2019 - 11:30 PM