Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / May 2008

Tip: Looking for answers? Try searching our database.

use the Form property to refer to a form associated with a subform

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ayaz Hoda - 13 May 2008 14:33 GMT
When button_1 clicked

it must sets price of specific item in a sub form specific row using
following code
Forms(formA)(formB)!Price.SetFocus

But it always set prices of first row of formB instead of setting price for
3rd or 4th row of sub form

so Is there anyway I can set set focus to
formA > subform (formB) > row (2) in subform

I did find this article but it didn't help to that level

http://msdn.microsoft.com/en-us/library/aa195905(office.11).aspx
Albert D. Kallal - 13 May 2008 15:08 GMT
> When button_1 clicked
>
[quoted text clipped - 5 lines]
> for
> 3rd or 4th row of sub form

You have to as a rule tell me how you decide it going to be the 3, or 4th
row. As a general rule, you should use the primary key value of a **row** to
define how you are going to update data in a table:

eg:

currentdb.Execute "update tableName set Price = 123 where id = 34433"

You can certainly "move" the sub-form to a particular record, and then
update it that way, but it not the usual approach.

However, here is a code snip  to udpate the 4th reocrd price field

 Me.MySubFormName.Form.Recordset.AbsolutePosition = 3
 me.MySubFormName!price = 123

AbsoultePosition is "zero" based, so in the above, 3 is the 4th reocrd.

Signature

Albert D. Kallal    (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com

--
Albert D. Kallal    (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com

Ayaz Hoda - 14 May 2008 09:31 GMT
This subform A is continous form,and display number of purchased items in
sales order.
This subform Ahas price box text field when cursor is at this textbox and
pressing F5, it display another form C which displays price list and user can
pick price from that form by click Paste price. and Price will appear on
subform A price box.
But problem is it always paste price in very first row of continous form
instead of setting price for 2nd or any other row

> > When button_1 clicked
> >
[quoted text clipped - 23 lines]
>
> AbsoultePosition is "zero" based, so in the above, 3 is the 4th reocrd.
Albert D. Kallal - 14 May 2008 12:43 GMT
> This subform A is continous form,and display number of purchased items in
> sales order.
[quoted text clipped - 5 lines]
> But problem is it always paste price in very first row of continous form
> instead of setting price for 2nd or any other row

I got the above.

Did you see/try the two lines of code I posted? It should work and allow you
to update the 4th record as you requested

give that sample code a try, here is the code again:

 Me.MySubFormName.Form.Recordset.AbsolutePosition = 3
 me.MySubFormName!price = 123

AbsoultePosition is "zero" based, so in the above, 3 is the 4th reocrd.

Signature

Albert D. Kallal    (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com

Albert D. Kallal - 14 May 2008 12:52 GMT
> This subform A is continous form,and display number of purchased items in
> sales order.
[quoted text clipped - 5 lines]
> But problem is it always paste price in very first row of continous form
> instead of setting price for 2nd or any other row

OK, when you launch that form C, and select the price value, your code to
update the sub-form price value should simply be:

forms!MainFormName!SubFormName!Price = me.Price (from form c).

I assume that form "c" is closed right after the person selects the price.
So, either use the close event of form c, or the after udpate event of the
combo box to "set" the value of price.

Your original request to say that you have to update the fourth record only
who was a bit confusing, and I now understand you simply want to update the
current record that the sub form happens to be on it that point in time when
you launch your view form "c".

The above syntax should allow you to do this, of course if you've got
anything that require ease the sub form, then that's going to mess this up.
on the other hand, there should be no need to read query this sub form
anyway.

Signature

Albert D. Kallal    (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com

Ayaz Hoda - 14 May 2008 14:51 GMT
Hi Albert

I am using following code which is similar to you
but same result

Forms(p)(c)!Price = Format(Me!Price, "#0.00")

Forms(p)(c)!Price.SetFocus

DoCmd.Close acForm, "PriceHelp"

Regards

Ayaz

> > This subform A is continous form,and display number of purchased items in
> > sales order.
[quoted text clipped - 24 lines]
> on the other hand, there should be no need to read query this sub form
> anyway.
Ayaz Hoda - 19 May 2008 10:43 GMT
In Access 2007 the F5 key executes a data refresh of the form.

Therefore when you press F5 the currentrecord in the subform is reset due to
the data refresh.

To solve this you need to cancel the data refresh as follows:

Wherever you have the code in for F5

If KeyCode = 116 Then 'Do Something ------------

Replace with

Private Sub Price_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 116 Then
   'Do something
   KeyCode = 0
End If
------

I hope this will help others encounter same issue

> Hi Albert
>
[quoted text clipped - 39 lines]
> > on the other hand, there should be no need to read query this sub form
> > anyway.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.