OpenForm with parameters

wllsth

Registered User.
Local time
Today, 10:47
Joined
Sep 17, 2008
Messages
81
I have 2 Tables - Property and Service

I want to add a new Service Record attached to my Property Record.

Key for Property Table is PropertyID
Key for Service Table is ServiceID
The records in Service Table also contain a field PropertyID which is the link/relationship between the tables.

I want to use OpenForm to add a new record from my existing Property Record and pass to it the PropertyID. Copy of cut-down database is attached. At present it opens new form but asks me to populate PropertyID using drop-down combo list
Any help would be appreciated
 

Attachments

I have 2 Tables - Property and Service

I want to add a new Service Record attached to my Property Record.

Key for Property Table is PropertyID
Key for Service Table is ServiceID
The records in Service Table also contain a field PropertyID which is the link/relationship between the tables.

I want to use OpenForm to add a new record from my existing Property Record and pass to it the PropertyID. Copy of cut-down database is attached. At present it opens new form but asks me to populate PropertyID using drop-down combo list
Any help would be appreciated

I don't understand your last paragraph or what you're trying to achieve. But from vague thoughts, if you use the OpenArgs property, and on the Onload event of the opening form, check that OpenArgs string for none empty string and use it to create your record
 
I can't open your attached database because it is done in version 2007. Please take care to mention this fact when posting a db. Everyone doesn't run it and downloading it is a waste of time for them.

Here is an example of what you're trying to do, if vbaInet and I are understanding you correctly. You'll have to change the names to reflect your own app.

In The calling form
Code:
Private Sub Go2SecondForm_Click()
If Not IsNull(Me.OrderID) Then
  DoCmd.OpenForm "SecondForm", , , , , , Me.OrderID
 Else
  MsgBox "A Visit ID Must Be Entered First!"
 End If
End Sub

In the called form
Code:
Private Sub Form_Load()

If Not IsNull(Me.OpenArgs) Then
   DoCmd.GoToRecord , , acNewRec
   Me.OrderID = Me.OpenArgs
 End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom