Same Record with another form

  • Thread starter Thread starter Zaradi Zakaria via AccessMonster.com
  • Start date Start date
Z

Zaradi Zakaria via AccessMonster.com

Hi,

Thanks for the prevoius reply, with the same project I just wonder how
could I make a form with datasheet view ,link to masterform and will reply
when I click with command button that datasheet view form will show all the
records that have been filterd by masterform.

Thanks in advance.

Eddy
 
Lacking an example, I can't give you specific advice, but in general, if
you add a Subform to a Form, linking the related fields when you do so,
this behavior is pretty much automatic -- except that you don't need a
command button. Changing the record selection in the master Form is all
you need to do to re-filter the Subform.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 
Hi ,

Yeah you right, that what I looking for, respon like Subform but it does'nt
attach at Masterform. I want it to be like this because that form will show
a lot of information so it does'nt appropriate to put togother in Masterform.
Means a user will use the Masterform to find record and click command button
to easily see all filter information in datasheet view (well I think using
another form much more better than right-click for datasheet view at
Masterform)

Vincent said:
Lacking an example, I can't give you specific advice, but in general, if
you add a Subform to a Form, linking the related fields when you do so,
this behavior is pretty much automatic -- except that you don't need a
command button. Changing the record selection in the master Form is all
you need to do to re-filter the Subform.

[quoted text clipped - 6 lines]
 
Your Forms do not need to show any more information than you wish --
just hide or delete any fields that you do not need.

There's nothing wrong with using a Command Button, but I am not
convinced that it's necessary. You could simply set the "On Click"
property of the list in the master Form to re-filter the datasheet.

Anyway, I set up some Tables and Forms to do something like what you
described.

Here are the Tables:

[SiteName] Table Datasheet View:

SiteNameID Name
----------- -------------
-1695578594 Moscow
-535197881 Point Barrow
46567804 Atlantis
155682225 Death Valley

[Weather] Table Datasheet View:

SiteNameID description Date
----------- ----------- -----------
-1695578594 Cold 12/11/2005
-1695578594 Dry 12/2/2005
-535197881 Cold 12/11/2005
46567804 Wet 12/11/2005
155682225 Hot 12/1/2005
155682225 Dry 12/2/2005

Query [Q_SiteNames] displays the place names in sorted order.

[Q_SiteNames] SQL:

SELECT SiteName.SiteNameID, SiteName.Name
FROM SiteName
ORDER BY SiteName.Name;

[Q_SiteNames] Query Datasheet View:
SiteNameID Name
------------ -------------
46567804 Atlantis
155682225 Death Valley
-1695578594 Moscow
-535197881 Point Barrow

Query [Q_Weather] displays selected records from the [Weather] Table.

[Q_Weather] SQL:
SELECT Weather.SiteNameID, Weather.description,
Weather.Date
FROM Weather
WHERE (((Weather.SiteNameID)
=[Forms]![F_Sites]![lbxMain]));

[Q_Weather] Query Datasheet View (if "Moscow" was selected in Form
[F_Sites]):

SiteNameID description Date
----------- ----------- ----------
-1695578594 Cold 12/11/2005
-1695578594 Dry 12/2/2005

I defined a Form, [F_Sites], with the following properties:
Record Source = Q_SiteNames

and containing a List Box, [F_Sites]![lbxMain], with the following
properties:
Row Source = Q_SiteNames
Bound Column = 1
Column Count = 2
Column Widths = 0;1
On Click = [the following Event Procedure:]

Private Sub lbxMain_Click()

Me.Recordset.FindFirst _
"SiteNameID=" & Me.lbxMain.Value

' Close F_Subform if it's open
DoCmd.Close acForm, "F_Subform"

' Requery F_Subform
DoCmd.OpenForm "F_Subform", _
View:=acFormDS, _
DataMode:=acFormReadOnly, _
OpenArgs:=acNormal

End Sub 'lbxMain_Click()


For the Subform, I merely ran the Form Wizard on [Q_Weather] and named
the new Subform [F_Subform]. It's not really a Subform, though, just a
separate Form that we're treating like a Subform. You might want to
hide the linking key field in [F_Subform].

Clicking on a name in the list box opens [F_Subform] and displays the
records related to the name you clicked. If you'd rather use a separate
Command Button, attach the code in function lbxMain_Click() to the
Command Button's "On Click" event instead.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
Hi ,

Yeah you right, that what I looking for, respon like Subform but it does'nt
attach at Masterform. I want it to be like this because that form will show
a lot of information so it does'nt appropriate to put togother in Masterform.
Means a user will use the Masterform to find record and click command button
to easily see all filter information in datasheet view (well I think using
another form much more better than right-click for datasheet view at
Masterform)

Vincent said:
Lacking an example, I can't give you specific advice, but in general, if
you add a Subform to a Form, linking the related fields when you do so,
this behavior is pretty much automatic -- except that you don't need a
command button. Changing the record selection in the master Form is all
you need to do to re-filter the Subform.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.


[quoted text clipped - 6 lines]
 
Hi,
It takes me little bit time to make some modification with my query and form,
but anywhere it works. Thank so much with your help.

p/s-Proceed with Access Pages hooking with exsiting Access Database, where
can I find a great forum regarding using VB Script?

Vincent said:
Your Forms do not need to show any more information than you wish --
just hide or delete any fields that you do not need.

There's nothing wrong with using a Command Button, but I am not
convinced that it's necessary. You could simply set the "On Click"
property of the list in the master Form to re-filter the datasheet.

Anyway, I set up some Tables and Forms to do something like what you
described.

Here are the Tables:

[SiteName] Table Datasheet View:

SiteNameID Name
----------- -------------
-1695578594 Moscow
-535197881 Point Barrow
46567804 Atlantis
155682225 Death Valley

[Weather] Table Datasheet View:

SiteNameID description Date
----------- ----------- -----------
-1695578594 Cold 12/11/2005
-1695578594 Dry 12/2/2005
-535197881 Cold 12/11/2005
46567804 Wet 12/11/2005
155682225 Hot 12/1/2005
155682225 Dry 12/2/2005

Query [Q_SiteNames] displays the place names in sorted order.

[Q_SiteNames] SQL:

SELECT SiteName.SiteNameID, SiteName.Name
FROM SiteName
ORDER BY SiteName.Name;

[Q_SiteNames] Query Datasheet View:
SiteNameID Name
------------ -------------
46567804 Atlantis
155682225 Death Valley
-1695578594 Moscow
-535197881 Point Barrow

Query [Q_Weather] displays selected records from the [Weather] Table.

[Q_Weather] SQL:
SELECT Weather.SiteNameID, Weather.description,
Weather.Date
FROM Weather
WHERE (((Weather.SiteNameID)
=[Forms]![F_Sites]![lbxMain]));

[Q_Weather] Query Datasheet View (if "Moscow" was selected in Form
[F_Sites]):

SiteNameID description Date
----------- ----------- ----------
-1695578594 Cold 12/11/2005
-1695578594 Dry 12/2/2005

I defined a Form, [F_Sites], with the following properties:
Record Source = Q_SiteNames

and containing a List Box, [F_Sites]![lbxMain], with the following
properties:
Row Source = Q_SiteNames
Bound Column = 1
Column Count = 2
Column Widths = 0;1
On Click = [the following Event Procedure:]

Private Sub lbxMain_Click()

Me.Recordset.FindFirst _
"SiteNameID=" & Me.lbxMain.Value

' Close F_Subform if it's open
DoCmd.Close acForm, "F_Subform"

' Requery F_Subform
DoCmd.OpenForm "F_Subform", _
View:=acFormDS, _
DataMode:=acFormReadOnly, _
OpenArgs:=acNormal

End Sub 'lbxMain_Click()

For the Subform, I merely ran the Form Wizard on [Q_Weather] and named
the new Subform [F_Subform]. It's not really a Subform, though, just a
separate Form that we're treating like a Subform. You might want to
hide the linking key field in [F_Subform].

Clicking on a name in the list box opens [F_Subform] and displays the
records related to the name you clicked. If you'd rather use a separate
Command Button, attach the code in function lbxMain_Click() to the
Command Button's "On Click" event instead.

[quoted text clipped - 20 lines]
 
Zaradi said:
Hi,
It takes me little bit time to make some modification with my query and form,
but anywhere it works. Thank so much with your help.

You're most welcome ... I tried to make it easy to use, am happy you
were able to make it work.
p/s-Proceed with Access Pages hooking with exsiting Access Database, where
can I find a great forum regarding using VB Script?
[...]

-- poyo's
Message posted via AccessMonster.com

I don't have any suggestions for this, suggest you re-post it in a new
thread to encourage someone else to answer.

-- Vincent Johns <[email protected]>
Please feel free to quote anything I say here.
 

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

Back
Top