473,788 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Confused about docmd.openform

formA determines some_where and some_value and issues

docmd.close ,Me
docmd.openform "formB", , ,some_where, , ,some_value

formB receives the correct some_where and some_value
After completing its work formB issues

docmd.close ,Me
docmd.openform "formA"

formA determines a new some_where and some_value and again issues

docmd.close ,Me
docmd.openform "formB", , ,some_where, , ,some_value

formB receives the correct some_where but no update of some_value

I also note that the forms' OnOpen event-code executes only the first
time that the forms are opened. How do I pass a new OpenArgs value to
formB after the first time?

I'm suspicious about where I've placed the close statements, but
neither order makes sense to me: if I close the form first, how does
the closed form execute the open statement that comes after the close
statement? ...but if I open the next form first, haven't I left the
environment where the close statement exists? And if my open
statements are failing, then why is *part* of the open statement
executing correctly [the some_where]?

--thelma
rephrasing an unanswered question

Nov 13 '05 #1
15 3897
I have only a few bits here.

I suggest docmd.close acform, me.Name (you have just Me and I explicitly
address the Name property; I added the acform to be sure)

The Close event happens before Unload. That means the closing form can
still execute code. Anyway, as long as the events run, the code still
executes, I can't recall interruption there.

I suspect that when you open form A from form B, and form A opens form
B, code execution has not ended before OpenForm is reached, so form B
has never left memory. But that is just a guess.

I only recently tried to pass a new OpenArgs (because the called form
does something with it, of course) and failed. So, I created a public
sub in the form (routines in a form are private by default) that does
the settings. I can then call this from its own Open event, but the
caller can also call it.

So instead of

docmd.openform theform, openargs:= some_value

you can write

docmd.openform theform
forms!theform.S ync some_value

inside the form module you have

Public Sub Sync(theValue as Whatever)
' your code
End Sub
Thelma Lubkin wrote:
formA determines a new some_where and some_value and again issues

docmd.close ,Me
docmd.openform "formB", , ,some_where, , ,some_value

formB receives the correct some_where but no update of some_value

I also note that the forms' OnOpen event-code executes only the first
time that the forms are opened. How do I pass a new OpenArgs value to
formB after the first time?

I'm suspicious about where I've placed the close statements, but
neither order makes sense to me: if I close the form first, how does
the closed form execute the open statement that comes after the close
statement? ...but if I open the next form first, haven't I left the
environment where the close statement exists? And if my open
statements are failing, then why is *part* of the open statement
executing correctly [the some_where]?

--thelma
rephrasing an unanswered question


--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html

Nov 13 '05 #2
rkc

Thelma Lubkin wrote:

I'm suspicious about where I've placed the close statements, but
neither order makes sense to me: if I close the form first, how does
the closed form execute the open statement that comes after the close
statement? ...but if I open the next form first, haven't I left the
environment where the close statement exists? And if my open
statements are failing, then why is *part* of the open statement
executing correctly [the some_where]?


Close the form second and all your problems are solved.
Code execution is "interrupte d" by the opening form's OnLoad
and OnOpen events, but returns to the procedure that issued the
open statement.

As for why part of the open statement is working, who knows unless
you show the actual code instead of an outline. If you are referencing
the form you just closed it should throw an error.

Nov 13 '05 #3
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote:

: Thelma Lubkin wrote:
:>
:> I'm suspicious about where I've placed the close statements, but
:> neither order makes sense to me: if I close the form first, how does
:> the closed form execute the open statement that comes after the close
:> statement? ...but if I open the next form first, haven't I left the
:> environment where the close statement exists? And if my open
:> statements are failing, then why is *part* of the open statement
:> executing correctly [the some_where]?

: Close the form second and all your problems are solved.
: Code execution is "interrupte d" by the opening form's OnLoad
: and OnOpen events, but returns to the procedure that issued the
: open statement.

: As for why part of the open statement is working, who knows unless
: you show the actual code instead of an outline. If you are referencing
: the form you just closed it should throw an error.

I tried it that way and OpenArgs are still not updating. Also,
this order of open, close produces erratic behavior: it often
doesn't respond to clicking the Return button [a toggle switch]
in formB, but not always. I wasn't able to do enough testing
to pick up the pattern of good and bad returns.

Thanks for trying.

--thelma


Nov 13 '05 #4
Bas Cost Budde <b.*********@he uvelqop.nl> wrote:
: I only recently tried to pass a new OpenArgs (because the called form
: does something with it, of course) and failed. So, I created a public
: sub in the form (routines in a form are private by default) that does
: the settings. I can then call this from its own Open event, but the
: caller can also call it.

: So instead of

: docmd.openform theform, openargs:= some_value

: you can write

: docmd.openform theform
: forms!theform.S ync some_value

: inside the form module you have

: Public Sub Sync(theValue as Whatever)
: ' your code
: End Sub
Thank you. This does work. But not from the OnOpen event,
because that is called only the first time that the form opens.
I'm using the OnCurrent event and I will now have to start
asking about why my attempt to use RecordSetClone to reset
the bookmark for a child of formB fails. But that's for another
thread.

Actually, my OpenArgs parameter is
so simple that I was able to communicate it simply by declaring an
existing global variable in formA as Public and referring to it in
formB by its full formal name

I still am interested in getting the open, close, dance of the
two forms working
--thelma
: Bas Cost Budde, Holland
: http://www.heuveltop.nl/BasCB/msac_index.html

Nov 13 '05 #5
rkc
Thelma Lubkin wrote:
rkc <rk*@rochester. yabba.dabba.do. rr.bomb> wrote: : As for why part of the open statement is working, who knows unless
: you show the actual code instead of an outline. If you are referencing
: the form you just closed it should throw an error.

I tried it that way and OpenArgs are still not updating. Also,
this order of open, close produces erratic behavior: it often
doesn't respond to clicking the Return button [a toggle switch]
in formB, but not always. I wasn't able to do enough testing
to pick up the pattern of good and bad returns.

I'd really like to see your code because I cannot make what you say is
happening happen. You are doing something to make it happen. Identify
what that is and stop doing it.

A return toggle button? What's that about?

Post the actual code.

Nov 13 '05 #6
Try the Activate event of the form, maybe. That fires every time the
form comes up front.

I meant to call my public sub from the caller! There is no Open event
running then.

Why do you close formA in the first place? In the end, you want it to be
open, albeit with new values?

--
Bas Cost Budde, Holland
http://www.heuveltop.nl/BasCB/msac_index.html

Nov 13 '05 #7
The requirement that needs this type of solution has me intrigued!
Assuming there's no other way around it, the following alternative
might be a solution.
It uses predeclared identifiers instead of OpenArgs to directly
call public functions in each form, handing over control
and passing parameters at the same time.
(Invoking a public function like this automatically
opens the form).

To test:
Build two forms, formA and formB.
FormA has one command button to kick the process off,
named cmdCallFormB.

If you create the two forms, add the code below,
open formA and click the button, the two forms will
swap data back and forth, printing the progress
in the debug window, until it stops at an arbitrary
point in fnA.
Here is the code behind formA:

'----------------------------------
Public Function fnA(param1, param2)
Debug.Print "A got " & param1 & " " & param2 & _
";About to close and call formB"
DoCmd.Close acForm, Me.Name
If Len(param1) < 8 Then
Form_formb.fnB param1 & "A", param2 & "A"
Else
Debug.Print "finished"
Stop
End If
End Function
Private Sub cmdCallFormB_Cl ick()
'The whole show starts here
Dim i
For i = 1 To 100
Debug.Print " "
Next i
Debug.Print "About to close and call form b with A1,A2"
DoCmd.Close acForm, Me.Name
Form_formb.fnB "A1", "A2"
End Sub
'----------------------------------
formB has just this code behind it:
'----------------------------------
Public Function fnB(param1, param2)
Debug.Print "B got " & param1 & " " & param2 & "; about to close and
call fnA"
DoCmd.Close acForm, Me.Name
Form_forma.fnA param1 & "B", param2 & "B"
End Function
'----------------------------------

HTH

Terry Bell
Melbourne Australia
Thelma Lubkin wrote:
formA determines some_where and some_value and issues

docmd.close ,Me
docmd.openform "formB", , ,some_where, , ,some_value

formB receives the correct some_where and some_value
After completing its work formB issues

docmd.close ,Me
docmd.openform "formA"

formA determines a new some_where and some_value and again issues

docmd.close ,Me
docmd.openform "formB", , ,some_where, , ,some_value

formB receives the correct some_where but no update of some_value

I also note that the forms' OnOpen event-code executes only the first
time that the forms are opened. How do I pass a new OpenArgs value to
formB after the first time?

I'm suspicious about where I've placed the close statements, but
neither order makes sense to me: if I close the form first, how does
the closed form execute the open statement that comes after the close
statement? ...but if I open the next form first, haven't I left the
environment where the close statement exists? And if my open
statements are failing, then why is *part* of the open statement
executing correctly [the some_where]?

--thelma
rephrasing an unanswered question


Nov 13 '05 #8
rkc
Thelma Lubkin wrote:

<snip all>

I do not see any reason to do battle with the simple way that
Access provides to do what you want to do.

Open the Agency form to a specific agency using:

strfilter = "agencyid = " & AgcID
DoCmd.OpenForm DoCmd.OpenForm "agency0toD ", _
acNormal, , strFilter, _
acFormReadOnly, acWindowNormal, _
empID
DoCmd.Close , "frmChooseAgenc y"

In that order.
Call that from the combo box OnClick event.

Return to frmChooseAgency from the agency form using:

DoCmd.OpenForm "frmChooseAgenc y"
DoCmd.Close acForm, Me.Name

Check for a valid empId in openArgs in the agency form's
OnLoad Event. If one is found do your subform navigation
by calling a sub routine defined in the subform's code
module.

The only part of this that should be even a minor challenge
is getting the subform navigation right. First you have to
position the agency form on the agency the employee works
for. Then you have to navigate to that person in the subform.

Take baby steps. Get the opening and closing of the agency form
right. When that's working move on to the subform navigation
and don't change anything that's working.

Nov 13 '05 #9
"Thelma Lubkin" wrote
Public AgcID, EmpKey As Long
Dim AgcCol, PCnt As Integer
Dim GString As String


Thelma, unless you are aware that AgcID and AgcCol are defined here as
Variants, you could be in for some surprises sometime. In VBA, each variable
must have its own "as Clause". My guess is that you intend, as is the case
in many other languages, but not in VBA, that AgcID be a Long, and AgcCol be
an Integer. If so, this should be rewritten as:

Public AgcID as Long, EmpKey As Long
Dim AgcCol as Integer, PCnt As Integer
Dim GString As String

I doubt that has anything to do with the problem you describe, but it's a
habit that you need to develop, lest you get some surprises later.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3991
by: Aravind | last post by:
Hi folks. I have 2 forms, frmMain and frmHistory. frmHistory has a field called Return. frmMain has a command button called "Due Today" (which will henceforth be called as DT), which opens frmHistory and filters it to display records where the value of Return is Null
6
4200
by: beowulfs | last post by:
Here's what I've got: I've got a form with combo boxes. you can select already existing company names or type in new ones. if you type in a new one, it prompts you to double click the combo box if you want to add a new company. when you double click it brings up the new company form so you can enter the rest of the information besides just the name there. This all works. Here's what I want:
3
4520
by: Lyn | last post by:
Hi, I have a Search input form which collects from the user a person's name. I am using LIKE with a "%" suffix in the SQL so that the user does not have to type in the full name. When they hit the Search button, a query is run to search the Person table for a match. This produces a recordset (I am using ADO). If the RecordCount is zero, they get a No Match message. If the RecordCount is 1, a DoCmd.OpenForm is performed to open the...
8
13213
by: John Welch | last post by:
I have a command button with the following code: DoCmd.OpenForm "frmSearchAssignments", , , "SearchAssignmentID = 1" (SearchAssignmentID is the PK, auto number) When it runs, the form opens but shows all records, rather than going to the one I want. If I look at the form in design view, it shows 'SearchAssignmentID=1' (without quotes) as the filter in the properties list. frmSearchAssignments is bound to a query qrySearchAssignments....
2
6865
by: Mike | last post by:
I am trying to open a search results form based on the input from a prompt form. I am using the following code: --- Begin Code --- Private Sub btnSearch_Click() 'Dim Variable and assign data Dim srce As String, fstnme As String, lstnme As String, bidnum As String srce = Me.Source_Control If Not IsNull(Me.Text18) Then
9
3522
by: keliie | last post by:
Hello (from Access novice), I'm building a switchboard form (using a Treeview object). The treeview is populated by two tables (tblSwitchboardParent and tblSwitchboardChild). Within tblSwitchboardChild, I have a string field called ChildArgument that contains string text of VBA code (e.g., DoCmd.OpenForm "myForm"). When users click on various portions of the Treeview object I want the Tree to either expand or open the report / form.
2
387
by: rturpyn | last post by:
I want to simply open a form, I don't want to limit the records returned. I'm using the code.... DoCmd.OpenForm "frm_GSG_Access_Rights", acFormDS, , When I enter something in the where ("Elist_Caption = 'GSG Model'") it does return my form with only 1 record. What am I missing? Thanks, -Turp
1
2718
by: silen | last post by:
i am using Access2000. Currently i had a main form call "frmDownload" and sub form "fsubAdmmission". Under the fsubAdmmission, i do have another sub form "fsubHospital". Once i link my application to database A, when "frmDownload" loaded, it does successfully create "fsubAdmmission" object and i am able to assign "fsubAdmmission.form.recordsource". Once i link my application to database B, when "frmDownload" loaded, it failed to assign...
5
4319
by: Lebbsy | last post by:
After displaying search results, I want to be able to double click the identity number field and then the input form SubmissionDetails becomes the display form for the results of the data matching value of the selected identity number. With my code below I get a data type mismatch error. Please help me....... Private Sub IdentityNumber_Click() On Error GoTo IdentityNumber_Click_Err On Error Resume Next If (Form.Dirty) Then ...
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10366
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.