open a form from a form

tbcwarrior

Registered User.
Local time
Today, 00:22
Joined
Oct 10, 2006
Messages
26
hi i have 2 tables with corresponding forms called
Form 1: main database
Form 2: customer 2

form 1 has a primary key field called: Case id (autonumbered)
form 2 has also a primary key field called: Case id (nuimber)

i have a check box on the FORM1 to open FORM2,

but what i want to do is open FORM2 with the same case id that is currently open in FORM1,

for example
FORM1 has a case id number of 10, and when i click on FORM2 atm it has a case number of 1, instead of 10 (case id 1 is a completely different customer to 10)

so what i want to do is when i open FORM2 from FORM1 i want FORM2 to have the same case id as FORM1

so is there a way to have a record be created with the same case id on FORM2 which is currently open on FORM1 when i click on the checkbox to open FORM2

hope this is clear what i am tryig to do

thanks
 
Last edited:
are we looking at 2 tables ??
if so you could have on open form2 push a button and it completes this info
but you do need to expand a bit on what you are asking

main form tied to main table
form 2 tied to ??
- bit more info will get more people interested in this
 
ill try to explain a bit better

main post edited
 
Last edited:
Hi,
I think your problem can be solved. The method goes like this:

1. Create a Custom property Named CusID (or whatever name you prefer)on your SubForm with the same data type of the CusID. Sample code is given below:

Public Function Create_Property()
Dim db As Database, doc As Document, prp As Property
Set db = CurrentDb
Set doc = db.Containers("Forms").Documents("SubForm")
Set prp = doc.CreateProperty("CusID", dbLong, 0)
doc.properties.Append prp
doc.properties.Refresh
End Function

Create the above Function in a Global Module and Run it from there itself so that the custom property can be created on the Subform in advance.


2. On the Click-Event of the Check Box on the MainForm Get the CusID on the Main Form and record it on the newly created Custom Property of the Subform before opening the SubForm. Code is given below:

Private Sub CheckBox_Click()
Dim db As Database, doc As Document
Set db = CurrentDb
Set doc = db.Containers("Forms").Documents("SubForm")

doc.properties("CusID").Value = Me![cusid]
doc.properties.refresh
docmd.OpenForm "SubForm", acViewNormal

End Sub

3. On the SubForm's OnLoad Event write the following code to get the Record of the same CusID on the SubForm:

Private Sub Form_Load()
Dim db As Database, doc As Document, x As Long
Set db = CurrentDb
Set doc = db.Containers("Forms").Documents("SubForm")

x = doc.properties("CusID").Value

Me.Filter = "Subform.CusId = " & x
Me.FilterOn = True

End Sub

I hope this will solve your problem. If you have time visit my site
http://msaccessblog.blogspot.com
 
tbcwarrior,

After reading your post, in my opinion you need a Main form with a linked Subform.

Have a look at my attached sample.
 

Attachments

thanks

thanks guys will try all above and let you know how i go
 
Sorted

Thanks very much guys i now have 2 links subforms working in my database

that example database helped greatly

regards
chris

:) :D
 

Users who are viewing this thread

Back
Top Bottom