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
8 18213 MSeda 159
Recognized Expert New Member
you could use some code in the subforms on current event to alter the parent forms recordsource. - Private Sub Form_Current()
-
Me.Parent.Form.RecordSource = "Select [myTable].* From [myTable] Where [myID] = " & Me.myID
-
End Sub
That's the simplest way I can think of.
Megan
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?
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: - 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...
MMcCarthy 14,534
Recognized Expert Moderator MVP
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: -
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
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...
MMcCarthy 14,534
Recognized Expert Moderator MVP
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
MSeda 159
Recognized Expert New Member
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: - Private Sub Form_Click()
-
DoCmd.GoToRecord acDataForm, "MainForm", acGoTo, Me.Form.CurrentRecord
-
End Sub
There’s probably at least a dozen other ways to do this if this one doesn’t work for you.
thanks, worked it out you ppl r, once again, legends
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 space.)
I would like the user to be able to select a record in the subform
datasheet, and click a button, or double click, to bring up the ENTIRE
record. (I would have a separate form created for this).
|
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 data in each record, which
includes the ID of the father and the mother (who also have records in the
table). One record per form.
I have a Tab Control in the form, and in one of the tabs I have a subform
(sfmSiblings) in which I wish to list...
|
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 user enters the
last qualifying field on the main form.
In one case this works fine, the subform shows the data the user wants
to update -- which means showing all the data put in previously (ie
showing this via the requery and the continuous...
|
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 many hours and for
which projects they've already made entries.
To do this, I created a query based on the same table with criteria
pointing to the current user, and the week selected in the main form.
This seems to work fine except the...
|
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 will relate to the same person - but
the subform data will not be 'linked' to the main form.
I want to have one Cancel button for all the undo operations on all the
subforms, so the individul subform's Public Sub, Form_Cancel will be called...
| |
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.
Tables: (abbreviated)
TblDivision
DivisionID
|
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
you enter data to the first field on the main form (a VIN#), that is
not the case. The SubForm control becomes disabled and will not
accept the focus. Dunno why. There's no child/master link fields.
They have no settings - at least not in design...
|
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 this is all very difficult to explain in words, please bear with me as I endevour to explain what it is I am trying to do. It would be helpful if I could attach a graphics file to this posting that would help explain what it is I'm trying to achieve...
|
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 a combo box with a Select query to select
one of the records in Table A. (The parent form is bound to Table A.)
I want to be able to first, view all of the corresponding records from
Table B and then second, give an option for editing these...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |