473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Controlling form's current record through selecting in a subform

15
Hi

I have a form called 'shiftviewer' and it contains a subform called 'all shifts for current month subform'. the subform is in datasheet view (access 2007) and the main form is a column orientated form.

Both forms contain records of 'shifts'
I want to be able to select a record (a shift) in the subform, and be able to set the parent form's current record to that record, through the identifying primary key that a shift record has (ShiftID)

I am semi capable of visual basic so hit me with it..
thank in advance
Jan 17 '07 #1
8 18198
MSeda
159 Expert 100+
you could use some code in the subforms on current event to alter the parent forms recordsource.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2. Me.Parent.Form.RecordSource = "Select [myTable].* From [myTable] Where [myID] = " & Me.myID
  3. End Sub
That's the simplest way I can think of.
Megan
Jan 17 '07 #2
anansi
15
Thanks thats working pretty well, not got it fully working, but will post when i'v had time. How to SELECT from myquery, not mytbl?
Jan 18 '07 #3
anansi
15
NOOOO!!

I accomplished what i wanted, but now, in the main form, all the controls are UNEDITABLE!

This defies the object. The code i put into the subform's current function is below:

Expand|Select|Wrap|Line Numbers
  1. Me.Parent.Form.RecordSource = "Select [personAndTime].promoID,[personAndTime].date,
  2. [personAndTime].time, [personAndTime].VenueID,
  3. [personAndTime].ActivityID,[Activities].rate,[Activities].hours,
  4. [Activities].otherPayments 
  5. From [personAndTime],[Activities] Where [ShiftID] = " & Me.ShiftID
The subform is however editable, not this is not necessary, what i wanted was to only be able to edit the subform through the main form...

thanks megan for so far...
Jan 18 '07 #4
MMcCarthy
14,534 Expert Mod 8TB
NOOOO!!

I accomplished what i wanted, but now, in the main form, all the controls are UNEDITABLE!

This defies the object. The code i put into the subform's current function is below:

Expand|Select|Wrap|Line Numbers
  1. Me.Parent.Form.RecordSource = "Select [personAndTime].promoID,[personAndTime].date,[personAndTime].time, [personAndTime].VenueID,[personAndTime].ActivityID,[Activities].rate,[Activities].hours,[Activities].otherPayments From [personAndTime],[Activities] Where [ShiftID] = " & Me.ShiftID
The subform is however editable, not this is not necessary, what i wanted was to only be able to edit the subform through the main form...

thanks megan for so far...
That's because you're selecting from a query not a table.

What I don't understand is the way you have this set up. The logic of changing a record on a main form based on the selection in a subform is the reverse of what is normally done. The best advice I can give is to open a new form instead with the appropriate record which should be editable.

Mary
Jan 18 '07 #5
anansi
15
That's because you're selecting from a query not a table.
Mary
I believe i am selecting from tables only. Activities and personAndTime are both tables. correct me if i am in the wrong.

The rational behind this form is that the user selects the item they want to edit from a datasheet subform, listing all the records in a viewable table format. the editing i want to have done must be done through the controls in the main form. but thats neither here not there.

Could you please explain why i cant edit the controls, if Activities and personAndTime are indeed tables, my FROM parameters. The subform however, is based on a query, so maybe im answering my own question...
Jan 18 '07 #6
MMcCarthy
14,534 Expert Mod 8TB
I believe i am selecting from tables only. Activities and personAndTime are both tables. correct me if i am in the wrong.

The rational behind this form is that the user selects the item they want to edit from a datasheet subform, listing all the records in a viewable table format. the editing i want to have done must be done through the controls in the main form. but thats neither here not there.

Could you please explain why i cant edit the controls, if Activities and personAndTime are indeed tables, my FROM parameters. The subform however, is based on a query, so maybe im answering my own question...
Your tables are being accessed through a query. When you put the further criteria on this query to bring up the new record the query becomes uneditable.

Mary
Jan 18 '07 #7
MSeda
159 Expert 100+
Sorry for the confusion I only tested the code on a form bound to a table not a query on two tables. Probably adding criteria to the query makes the recordset unupdateable

The following code should work and doesn’t alter the record source.

In the subform’s on click event:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Click()
  2.     DoCmd.GoToRecord acDataForm, "MainForm", acGoTo, Me.Form.CurrentRecord
  3. End Sub
There’s probably at least a dozen other ways to do this if this one doesn’t work for you.
Jan 18 '07 #8
anansi
15
thanks, worked it out you ppl r, once again, legends
Jan 21 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Phil Matish | last post by:
I would like to know if the following is possible: I have a form and a subform. In the subform, there are records summarized. (For ex, instead of showing all 19 fields, I only show 3 to save...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
1
by: New2Access | last post by:
Hi, I have a form thats used to enter records into a table. The table and form have fields for Name, week, project, and hours. To assist users, I wish to add a subform that will show them how...
18
by: Darryl Kerkeslager | last post by:
I don't do much with subforms - in fact I've deliberately avoided them - but .... I have a tab control that will contain several subforms, each bound to a separate table, and each table/subform...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
6
by: MLH | last post by:
When the vehicle entry form (frmVehicleEntryForm) first opens, the additional owner SubForm control (frmAddnlOwnrListSubForm) is enabled. You can click on it and it will accept the focus. But after...
4
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase...
1
by: troy_lee | last post by:
I have a table (Table A). It has one field, a PK. It is in a 1:M with another table (Table B). I am having trouble with a form/subform setup to view the 1:M records. On the parent form, there is...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.