Kudos to anyone who can explain this one--how to duplicate a group of
continuous records in a subform for use in a new subform PK ID. The 2
entry fields (combo boxes) in the subform are RoleID and StaffID, and
the PK ID is StaffandIntsID. The subform's data is put into
jtblStaffandInt s, which joins a Staff and Intervention tables:
So, here's what the data could look like in the table:
StaffandIntsID InterventionID StaffID RoleID
41 24 3 1
42 24 4 2
43 24 13 3
44 24 2 4
45 24 20 5
46 24 99 6
So, for a new Intervention entered (InterventionID = 25), the data may
look like
47 25 3 1
48 25 4 2
49 25 13 3
50 25 2 4
51 25 20 5
52 25 99 6
But, the user must be able to change the staff names, such as the
first record, StaffID = 3, to some other staff. And, users must be
able to delete a staff in the new record.
This subform is linked to another subform in the main form: child
field = InterventionID, master = [sfrmIntsPastDB].Form!
[InterventionID]
Thanks 3 1720 6a************* **@gmail.com wrote:
Kudos to anyone who can explain this one--how to duplicate a group of
continuous records in a subform for use in a new subform PK ID. The 2
entry fields (combo boxes) in the subform are RoleID and StaffID, and
the PK ID is StaffandIntsID. The subform's data is put into
jtblStaffandInt s, which joins a Staff and Intervention tables:
So, here's what the data could look like in the table:
StaffandIntsID InterventionID StaffID RoleID
41 24 3 1
42 24 4 2
43 24 13 3
44 24 2 4
45 24 20 5
46 24 99 6
So, for a new Intervention entered (InterventionID = 25), the data may
look like
47 25 3 1
48 25 4 2
49 25 13 3
50 25 2 4
51 25 20 5
52 25 99 6
But, the user must be able to change the staff names, such as the
first record, StaffID = 3, to some other staff. And, users must be
able to delete a staff in the new record.
This subform is linked to another subform in the main form: child
field = InterventionID, master = [sfrmIntsPastDB].Form!
[InterventionID]
Thanks
I know I don't understand the problem but...what the heck.
First, you could get the Max intervention ID. In this case it would be 24.
Dim strSQL As String
Dim dbs As Database
Dim MaxID As Long
MaxId = DMax("ID","Your Table")
'make an append query string to append the new records
strSQL = "INSERT INTO YourTable ( InterventID, StaffID, RoleID ) " & _
"SELECT " & MaxID + 1 & ", StaffID, RoleID " & _
"FROM YourTable " & _
"WHERE InterventID = " & MaxID
set dbs = currentdb
dbs.execute strSQL 'run the SQL statement
This will append all records from 24 into 25.
I appreciate it guys; I'll try it later tonight.
Here is my solution; thanks to your help. I put a cmd button
(cmdAppend) with the caption "Copy Staff to New Record" on the main
form. On its click event, I put this:
Dim strSQL As String
Dim dbs As Database
Dim PrevID As Long
Dim MaxID As Long
PrevID = Forms!frmInterv entions.txtPrev iousIntID 'Where on the
main form's open event, Me.txtPreviousI ntID = Me!sfrmIntsPast .Form!
InterventionID (renamed the 'DB' subform from above)
MaxID = DMax("Intervent ionID", "qryStaffAndInt s2") 'This query
filters interventions that are associated with only the current
student selected in main form
'make an append query string to append the new records
strSQL = "INSERT INTO jtblStaffAndInt s ( InterventionID, StaffID,
RoleID ) " & _
"SELECT " & MaxID & ", StaffID, RoleID " & _
"FROM jtblStaffAndInt s " & _
"WHERE InterventionID = " & PrevID
Set dbs = CurrentDb
dbs.Execute strSQL 'run the SQL statement
===============
cmdAppend's visible property is turned on/off depending on whether
there are any previous interventions entered for the student. So, I
hid a textbox, txtCount, in the footer of sfrmIntsPast that =
Count([InterventionID]).
Lastly, inside of sfrmIntsRecent, on the cmdbutton that 'saves and
goes to the staff subform,' I put:
If Me.Parent.txtCo unt = 0 Then
Me.Parent.cmdAp pend.Visible = False
Else
Me.Parent.cmdAp pend.Visible = True
End If This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: M Wells |
last post by:
Hi All,
I am developing an Access 2003 project application with the back end
in SQL Server 2003.
I have a master form that tracks projects, and several subforms on it
that track various aspects of the project. On the masterform I have
two unbound listboxes that I populate with information regarding the
current record in one of the subforms.
|
by: Richard Hollenbeck |
last post by:
I have a main form for entering students' grades. The main form indicates
which activity I will be entering.
The sub form on the right contains the actual score for the activity. It is
based on a table with a composite key (ActivityID and StudentID) and needs
to get those two key values populated with data from the main form and the
other sub form on the left. The ActivityID should automatically fill the
new records with the...
|
by: Richard Stanton |
last post by:
Hello all
My database has a main form linked to table1. It has several subforms
on the main form, all linked to table2. Table1 and Table2 are linked
by primary/foreign key, no duplicates allowed, one-to-one.
If I update field(s) on a single subform it works fine but when I
update fields on multiple subforms ie without closing the form between
updates, I get the following error:
|
by: tlyczko |
last post by:
I have a main form with 2 subforms, each subform references different
data in the same table.
How do I make sure each subform only creates NEW records in the
referenced table and do not overwrite or change data in previously
created rows??
Otherwise I have to use two different tables, with similar kinds of
data, for each subform, which may well be the way to go even though
it's not really normalized, to make the data entry easier and...
|
by: katedw203 |
last post by:
I'd like to delete this post
| |
by: Otis492 |
last post by:
Hello,
I have been struggling with this for a while. I am working on a rather simple database for claims in Access 2003. I have a table called claims that has a primary key field called Claim #. It is linked to a table called parts. The idea is that a claim can be filed for multiple damaged parts. In other words a claim # could have 0 to several damaged parts. My problem lies with the form that I have created. It is a main form with a...
|
by: Constantine AI |
last post by:
Hi can anybody help?
I have a main form with customer details on that links to a sales order head subform through the customer ID. The sales order head subform is then linked to the sales order line through the order no. I need to find a specific sales order number through the main form and once this number is chosen it needs to dispalay the relevant customer and order line details.
I have the following code but it filters the customer Id...
|
by: TD |
last post by:
I have a main form with two subforms (both in datasheet view), neither
of which are linked to the main form. The main form is based on a
query that uses the bound column of a combobox on the main form as the
criteria for the query. The combobox is based on a query that
retrieves the name and record id of the customers. In the afterUpdate
event of the combobox on the main form and both subforms are
requeried. The first subform is based...
|
by: SirTKC |
last post by:
Hi,
Here is the following scenario.
I do have a master table with related subforms from wich I need to
create a revision.
But I need to duplicate the content of the subforms and link them to
the new entry in the master table.
Each string possess its unique identifier number.
|
by: AccessBeetle |
last post by:
I am working with SQL server 2005 backend and Access 2003 frond end.
I have a form bound to a table tblReportDetails. There are several(5) tabs on the same form. Each tab has its own subform. Every other subform works fine but the very first tab has a subform which shows three cascading comboboxex, cmbCounty, cmbTownship, cmbQuad. cmbTownship and cmbQuad shows values based on the county selected in cmbCounty.
One record from the main form can...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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: 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |