Open a form from two different forms.

Ankarn

Registered User.
Local time
Today, 01:24
Joined
Jul 4, 2008
Messages
81
I have a form i want displayd when clicking a button in two different forms.

I have Form A, B and C. I want there to be a button in both Form A and B that both opens the Form C.

But heres the thing. I want the C to difference between being opened from A and B. If i open it from A, i want something slight different to happen than if i open it from form B.

How could i do this? I was thinking something like If IsOpen(A) Then, or something like that. I dont know if there is such a function, but thats why i'm asking.

Thanks in advance.
 
I think you can utilize the openArgs property for something like this - ?
 
how do i do that? I could also just make a variable that war true if i opened it from one form, and false if i opened it from something else.
 
thanks sir.

But its not quite like that, i dont want to type in a value, or display another value, i simply want a little bid of editing in my SQL string if i enter from A or B, because it has to read from a controll from A if it's opened in A, and it has to read from a controll in B if it opens from B.
 
I don't think you are seeing the big picture. When you open form c from form a you send something like "form_a" as the open arg. When you open it from form b the you send something like "form_b" as the open arg. Then in the form c on open event you do something like:

if me.openarg = "form_a" then
do some code
elseif me.openarg = "form_b" then
do some other code
end if

Make sense?

Or am I still missing something?
 
now we're making sense yes.. Thats what i want.

But i've never used openargs before. Do i just make a Integer, and make it openarg?

Lets say Set T As Integer, and set T = 1 in the Form A, and 2 in Form B. and then i can check if T is 1 or 2 in form C where i want the difference.

But where do i make it openarg? and can i just check for T in C? because it gets T from the previous form?
 
In form a you open form c with something like:

Code:
DoCmd.OpenForm "formc", , , , , , "form_a"
In form b you open form c with something like:
Code:
DoCmd.OpenForm "formc", , , , , , "form_b"
Then in the onOpen event for form c you do something like:
Code:
if me.openarg = "form_a" then 
   do some code
elseif me.openarg = "form_b" then 
   do some other code
end if
 
as it is now i use only DoCmd.OpenForm "FormC", i dont have much ,,,, after that.

Now i just put , "form_a" behind it? Openargs is the args you put behind the form you are opening?
 
Do you require Ken to copy the Access help on openargs for you.

Brian
 
allright.. now i think i understand

i have


MsgBox strSql
DoCmd.OpenForm "Adresse", , , , , , strSql


and in the form Adresse, i do CurrentDb.Execute strSql
which should work. It doesnt work because currentDb.Execute strSql is just the text "strSql"

ive used the msgbox as you can see to see if strMsg is the query in my previous form, and it is.

What am i doing wrong here?

Me.OpenArgs also only give "strSql"
 
i did that, as i said, Me.Openargs also gives me "strSql". It doesnt work either.
 
To start with what the heck is:

currentDb.Execute strSql

Supposed to be doing?
 
And of course you could use
If(IsLoaded) "Form1" Then
DoSomething
Else
DoSomethingElse
EndIf
 
ah.. ok. But now i want to do more than just know what form it's opened from. I want to use the openarg to something important.
 

Users who are viewing this thread

Back
Top Bottom