Linking forms

Andren

Registered User.
Local time
Today, 12:38
Joined
Sep 3, 2002
Messages
55
Hi!
By the help of Oldsoftboss I managed to set up a librarin database. Still working on it, I encounter some new problems.
One of these problems is that I want two forms to reflect the same reccord. First I had in mind to make it form-subform but
of practical/lay-out reasons this does not work. So I want to have a button from wich I can call an other form. But I want to be sure that both forms are pointing to the same reccord.
How do I do that?

Another question. How can I automatically make unnessecary forms close when I open a new form ? User of my data-base will walk through a tabbed notebook. On every page in the tabbed notebook users have the opportunity to open one of several subform. When not needed anymore - I want thos subforms to close down.

It is now 13.06 in Sweden. I can see that only me and Oldsoftboss is browsing this forum - although it must be middle in the night in Australia.... However - thanks again for your help Oldsoftboss.

/ Andren
 
You can use code like this to open a form at a specific record:

DoCmd.OpenForm "FormName", , ,"[ID] = " & Me.FieldWithID

I have assumed a unique field for each record call ID. Change this to reflect the actual name of your ID field.

I am not sure what you want to do in your second question but can you not just put a close button on the form so the user closes the popup form and returns to the form the just came from?

You can modify this code to close all open forms with the exception of the two forms that have been singled out to stay open:

Dim frm As Form
Dim a As Integer

For a = 1 To Forms.Count + 1

For Each frm In Forms
If frm.Name = "FormA" Or frm.Name = "FormB" Then
Else
DoCmd.Close acForm, frm.Name
End If

Next frm
Next a

hth,
Jack
 
Thanks

Thanks, Jack.
I'll try.

/ Anders
 
Hmm...

Actually I have an id field creatively labeled "Id" !!!
So it was not so difficult to apply your code:

DoCmd.OpenForm "FormName", , ,"[ID] = " & Me.FieldWithID

HOWEVER - applying that I get a compilation error saying "Method or data member not found".

In both forms I however have an Id-field.

Why is it this way ?

/ Anders

(PS: Another question from one who does not have english as native language - what does "HTH" stand for ? DS)
 
In this line of code:

DoCmd.OpenForm "FormName", , ,"[ID] = " & Me.FieldWithID

Replace FieldWithID with the name of the field on your form that has the ID in it. If, for example, your field is called ID then the code would read:

DoCmd.OpenForm "FormName", , ,"[ID] = " & Me.ID

If your field is named fldID then this is what you would want:

DoCmd.OpenForm "FormName", , ,"[ID] = " & Me.fldID

I hope that is a bit more clear.

HTH stands for Hope This Helps....

Good luck with this!

Jack
 
He,he...

YIHPT (Yes it helped
YSK (You are so kind)
ASG (I am so grateful)

ATB (All The Best) ...

/ Anders
 
GYGIWAGIWATH! (Glad You Got It Working And Glad I was Able To Help!)

Jack
 

Users who are viewing this thread

Back
Top Bottom