subforms

F

Francis

Following goes another atempt geting an answer, since my other message
noone has answered, i assume it's because they didn't saw it, and
avoiding it go away from the top im sending. If it's spam is not my
pourpose hence this introduction following.

hello i have a form that's commercialconditions, and another
commercialconditions_EditForms, which look like this:

CommercialConditions (Form1)
IDcomcond (autonum)
combobox1 (cbo)
business (text)
....


CommercialConditions_Editforms (Form2)
IDcomcond (autonum)
combobox1 (cbo)
business(text)
....


For some reasons i want to open form2, to edit the information in cbo
Form1, and im using openArgs , to pass the value of IDcomcond, i
validate that it isnt null in first place, and i store the value of
IDcomcond successfully in the openargs.


I'm using the gotfocus event in combobox1 Form1, the problem is that
when i openform Form2 im using:
DoCmd.GoToControl ctrlcombobox1
DoCmd.GotoRecord Me.OpenArgs


I tdoenst work bcose the form1 is still in edit mode, and record hasnt
been yet stored in DB fully.

Oh basically Form1 and Form2 have the same structure, but i use form2
to edit combobox1 besides the other data, because Form1's combobox1
isnt updateable by reasons concerning my forms goals

Thanks in advance for any answers
Francis
 
G

Guest

You don't need to pass the value of the IDcomcond field to the second form as
its OpenArgs property; just open the second form filtered to that record.
Before doing so you need to save the current record in the first form. So
the code in the first form's module to do this would be something like this:

Dim strCriteria As String

' first save current record
RunCommand acCmdSaveRecord
' build criterion for opening second form
strCriteria = " IDcomcond = " & Me.IDcomcond
' open second form filtered to current record
DoCmd.OpenForm "Form2", _
WhereCondition:=strCriteria, _
WindowMode:=acDialog

This will open the second form in dialog mode, so you won't be able to
return to Form1 until Form2 is closed. In Form2's Load event procedure you
can move focus to the combo box if you wish:

Me.ctrlcombobox1.SetFocus

Ken Sheridan
Stafford, England
 
F

Francis

Ok Thanks Ken Sheridan, the problem is that there are some required
fields that may not be yet filled, so access will give an error
statement that can't save the record because it's required a given
field..

So it really doesn't sort the problem. although it was a smart tthing
and a nice idea :) I was more directed to fiddle with the dirty
property, and oldvalue vs value property. One thing that can be used in
this case, is that whenever the user enters the combobox1, there is
already the IDcomcond field filled (due to user input validation code i
have already builden), so even if the record cant be fully saved, still
the columns/fields that talready are filled have their value and
oldvalue properties with different values. If we use the recordset
clone DB in Form2 aproach perhaps we can sort this, error free and
interface wise.

Another option is to copy all present values of the fields to an array
or to a recordset, to check if each value is different, and if is, to
update it, so the user will be taken to the exact situation he was when
he was in form1. For instance:

user inputs in form1: in field [business]= "supply" (autonumber
generates IDComCond = 8), in required field [discount]="135%", leaving
the field [units] (required) and the field observations (optional)
blank.
then clicks on the combobox1, thus it opens the Form2, and supposedly
user should see in each field of form2 (remember forms have exactly the
field same structure) exactly the informations he had in Form1, wether
he was adding a new record, or editing a new record.

I think this has another way around, but i really want to explore this
feature, since it might come up in some other form i'm building.

Thanks in advance for answering.
Francis (Portugal - Évora - Lisboa)



Ken Sheridan escreveu:
 
G

Guest

Francis:

I'd suggest that you use an unbound form as the second form, with an unbound
combo box on it. You can then assign its value to the current record on the
first form when the second form is closed. The code in the first form's
module to open the second form would be like this:

DoCmd.OpenForm "Form2", _
WindowMode:=acDialog, _
OpenArgs:=Me.Name

This open the second form in dialog mode, passing the first form's name to
it as its OpenArgs property.

In the second form's Close event procedure you can then assign the value
selected in the unbound combo box to the combo box on the first form:

Dim strForm as String

strForm = Me.OpenArgs

Forms(strForm).ctrlcombobox1 = Me.ctrlcombobox1

If you feel its necessary to show the values from Form1's other controls in
Form2 then you can pass these also to the second form by means of the
OpenArgs mechanism. You can download a demo of mine which, among other
things, shows how to pass multiple named arguments in this way, from the
following link:


http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=24091&webtag=ws-msdevapps


By incorporating the module from my demo in your application you can pass
each value from the controls on Form1 as named arguments, then insert them
into unbound controls on Form2 with code in Form2's Load event procedure.

Ken Sheridan
Stafford, England

Francis said:
Ok Thanks Ken Sheridan, the problem is that there are some required
fields that may not be yet filled, so access will give an error
statement that can't save the record because it's required a given
field..

So it really doesn't sort the problem. although it was a smart tthing
and a nice idea :) I was more directed to fiddle with the dirty
property, and oldvalue vs value property. One thing that can be used in
this case, is that whenever the user enters the combobox1, there is
already the IDcomcond field filled (due to user input validation code i
have already builden), so even if the record cant be fully saved, still
the columns/fields that talready are filled have their value and
oldvalue properties with different values. If we use the recordset
clone DB in Form2 aproach perhaps we can sort this, error free and
interface wise.

Another option is to copy all present values of the fields to an array
or to a recordset, to check if each value is different, and if is, to
update it, so the user will be taken to the exact situation he was when
he was in form1. For instance:

user inputs in form1: in field [business]= "supply" (autonumber
generates IDComCond = 8), in required field [discount]="135%", leaving
the field [units] (required) and the field observations (optional)
blank.
then clicks on the combobox1, thus it opens the Form2, and supposedly
user should see in each field of form2 (remember forms have exactly the
field same structure) exactly the informations he had in Form1, wether
he was adding a new record, or editing a new record.

I think this has another way around, but i really want to explore this
feature, since it might come up in some other form i'm building.

Thanks in advance for answering.
Francis (Portugal - Évora - Lisboa)
 
F

Francis

wowish thank you... your function sorts so much problems... and it
works great.

Ok i have my database running smoothly now, i just use an unbound form,
with link to he subform where the records are. I make sure any data is
passed to the unbound form, with this function (it's more then four/six
fields that i'm passing each time, it works very good indeed so thanks)
so i edit/add the informations in the unbound fields.

It works thank you again for teh infos

Francis
(Évora Portugal)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top