Welcome to Windows Help!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

A Form that leads to a second Form

 
   Windows Help (Home) -> Microsoft Access RSS
Next:  Copying from excel and pasting as a metafile in p..  
Author Message
Emma

External


Since: Nov 25, 2008
Posts: 14



(Msg. 1) Posted: Fri May 08, 2009 12:54 pm
Post subject: A Form that leads to a second Form
Archived from groups: microsoft>public>access (more info?)

I have a button on my first form that opens up a second form which has a
button on it leading to a third form. I would like the 3rd form to gather the
client Name, Phone, ID from the first form. But when I do this I get the 1st
record in the database instead of the current client. So my question is how
do I pass that information along? I sort of remember using something like
[forms]![2nd form]![name] but not sure how this works in my query. Or do I
need to base my query on the 2nd form query?

 >> Stay informed about: A Form that leads to a second Form 
Back to top
Login to vote
Steve

External


Since: May 8, 2009
Posts: 1



(Msg. 2) Posted: Fri May 08, 2009 4:40 pm
Post subject: Re: A Form that leads to a second Form
Archived from groups: per prev. post (more info?)

The first form needs to be open. It can be not visible. It needs to include
client Name, Phone and ID. The third form can gather the three fields from
the first form with:
MyClientName = Forms!NameOfFirstForm![Client Name]
ClientPhone = Forms!NameOfFirstForm!Phone
ClientID = Forms!NameOfFirstForm!ID

Steve
santus.Rmv RemoveThis @penn.com




"Emma" wrote in message

>I have a button on my first form that opens up a second form which has a
> button on it leading to a third form. I would like the 3rd form to gather
> the
> client Name, Phone, ID from the first form. But when I do this I get the
> 1st
> record in the database instead of the current client. So my question is
> how
> do I pass that information along? I sort of remember using something like
> [forms]![2nd form]![name] but not sure how this works in my query. Or do I
> need to base my query on the 2nd form query?

 >> Stay informed about: A Form that leads to a second Form 
Back to top
Login to vote
ken

External


Since: May 4, 2009
Posts: 3



(Msg. 3) Posted: Sat May 09, 2009 10:19 am
Post subject: Re: A Form that leads to a second Form
Archived from groups: per prev. post (more info?)

The best way to do this is to pass the values by means of the OpenArgs
mechanism; this allows for the calling form to be closed, or for the
called form to be opened in dialogue mode if necessary so that code
execution in the calling procedure will be suspended pending the
closure of the called form.

If the third form is a bound one which includes the client's ID in its
underlying table or query then you can filter the third form on
opening by means of the WhereCondtion argument of the OpenForm
method. So the code to open the second form would be:

DoCmd.OpenForm "[2nd Form]", _
OpenArgs:=Me.[ID]

The code to open the third form would be:

DoCmd.OpenForm "[3rd Form]", _
WhereCondition:="[ID] = " & Me.OpenArgs

Another possible scenario is that you are inserting a new row into the
table underlying the third form and wish it to reference the current
client. In this case you'd

Note that the DefaultValue property is a string expression, regardless
of the underlying data type of the column in question; hence the
delimiting quotes characters. In this scenario the name and phone
number should again be in computed controls as above, not stored in
columns in the underlying table as that introduces redundancy and
leaves the table open to inconsistent data being entered. In this
case you'd open the third form at a new record and pass the ID again
with:

DoCmd.OpenForm "[3nd Form]", _
DataMode:=acFormAdd, _
OpenArgs:=Me.OpenArgs

and in the third form's Open event procedure set the DefaultValue
property of the (bound) txtID control in the third form in its Open
event procedure with:

Me.txtID.DefaultValue = """" & Me.OpenArgs & """"

to show the client name and phone number in the third form either base
it on a query which includes the Clients table or use computed
controls with ControlSource properties of:

=DLookup("ClientName", "Clients", "ID = " & Me.txtID)

=DLookup("Phone", "Clients", "ID = " & Me.txtID)

or make the ID column's control a combo box which includes the name
and phone number in its RowSource e.g.

ControlSource: ID

RowSource: SELECT ID, Phone, ClientName FROM Clients ORDER BY
ClientName;

BoundColum: 1
ColumnCount: 2
ColumnWidths: 0cm;0cm;8cm

If your units of measurement are imperial rather than metric Access
will automatically convert the above to inches. The important thing
is that the first two dimensions of the ColumnWidths property are zero
to hide them.

Then include an unbound text box to show the phone number by
referencing the second column of the combo box with a ControlSource
property such as:

=cboID.Column(1)

The Column property is zero-based so Column(1) is the second column.

For more flexible ways of using the OpenArgs mechanism, involving the
passing of a value list or named arguments see:

[URL="http://community.netscape.com/n/pfx/forum.aspx?nav=libraryMessages&tsn=1&tid=24091&webtag=ws-msdevapps"]http://community.netscape.com/n/pfx/forum.aspx?nav=libraryMessages&tsn=1&tid=24091&webtag=ws-msdevapps[/URL]

Ken Sheridan
Stafford, England

On May 8, 8:54 pm, Emma wrote:
> I have a button on my first form that opens up a second form which has a
> button on it leading to a third form. I would like the 3rd form to gather the
> client Name, Phone, ID from the first form. But when I do this I get the 1st
> record in the database instead of the current client. So my question is how
> do I pass that information along? I sort of remember using something like
> [forms]![2nd form]![name] but not sure how this works in my query. Or do I
> need to base my query on the 2nd form query?
 >> Stay informed about: A Form that leads to a second Form 
Back to top
Login to vote
Emma

External


Since: Nov 25, 2008
Posts: 14



(Msg. 4) Posted: Mon May 11, 2009 7:20 am
Post subject: Re: A Form that leads to a second Form
Archived from groups: per prev. post (more info?)

Sweet, I fixed my query and it works like a charm, Thanks

"Steve" wrote:

> The first form needs to be open. It can be not visible. It needs to include
> client Name, Phone and ID. The third form can gather the three fields from
> the first form with:
> MyClientName = Forms!NameOfFirstForm![Client Name]
> ClientPhone = Forms!NameOfFirstForm!Phone
> ClientID = Forms!NameOfFirstForm!ID
>
> Steve
> santus.Rmv.DeleteThis@penn.com
>
>
>
>
> "Emma" wrote in message
>
> >I have a button on my first form that opens up a second form which has a
> > button on it leading to a third form. I would like the 3rd form to gather
> > the
> > client Name, Phone, ID from the first form. But when I do this I get the
> > 1st
> > record in the database instead of the current client. So my question is
> > how
> > do I pass that information along? I sort of remember using something like
> > [forms]![2nd form]![name] but not sure how this works in my query. Or do I
> > need to base my query on the 2nd form query?
>
>
>
 >> Stay informed about: A Form that leads to a second Form 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Form calculations - I have a form that calculates totals when it is opened. I do not want the user to be able to do anything until the form completly calculates, this may take up to 10 seconds. how do I keep the user from clicking on anything until the form is..

Rebuilding a form - A2003: I inherited an mdb of which one form occasionally causes corruption. No backup available, I made one now. I also took measures to prevent this mdb from further corruption. I want to create a new form and drag all fields from the old form on top...

can't insert a form into a report - access 2007 won't display a form inserted into a report. This worked with Access 2003. Any ideas???

Validation rule for a form - How can I make Access check if two fields are not duplicated? i.e. one employee file number cannot have the same application number more than one time.

Using Form Between 2002/2007 - User has Access 2002 SP3 User has an every 3-year process whereby an Access 2002 form is sent out to registrants of a program to be completed and returned. However, they are now finding that many of the registrants have Access 2007 and none of the ..
   Windows Help (Home) -> Microsoft Access All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]