473,382 Members | 1,261 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,382 software developers and data experts.

Insert many values into separate table (VBA) from Multiple Items Form

Hello!

I have a multiple value form: sbfrmTests_multi
*Please ignore sbfrm - at present that is the name, but it has no parent.

- Form use: select tests and insert them into a template with the same templateID.

I have a static table: tblTests
-A table of tests, to populate the selection options (Checkboxes) on sbfrmTests_multi

I have a data entry table: TestRecord
-A table to hold the templateID and the tests selected from sbfrmTests_multi

When you select the available options, the form returns with the tests selected:

The form's data source is a Select Totals query (to prevent duplicate records):
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCTROW Testing.testid, Testing.TestCategory, Testing.Test, Max(Testing.TestMethod) AS MaxOfTestMethod, Max(Testing.NPN) AS MaxOfNPN, Max(Testing.Cosmetic) AS MaxOfCosmetic, Max(TestRecord.TemplateID) AS MaxOfTemplateID, Max(TestRecord.TestRecordID) AS MaxOfTestRecordID
  2. FROM Testing, CoATemplate, TestRecord
  3. GROUP BY Testing.testid, Testing.TestCategory, Testing.Test
  4. HAVING (((Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_hm] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_hma] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_mb] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_mb2] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_pe] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_rs] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_pc] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_me] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_bo] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_ad1] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_ad2] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_wa] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_cu1] Or (Testing.TestCategory)=[forms]![sbfrmTests_multi]![t_cu2]))
  5. ORDER BY Testing.TestCategory, Testing.Test;

I added two unbound textboxes to the form: (TemplateID_1) that will eventually auto-populate from a parent form (header), (TemplateID_2) in the data field entry of the multiple items form.

TemplateID_2 updates to = TemplateID_1 (working as desired).

What I need is a command button to insert all visible records from the multi-select form into another table.

So if I select test a, b and c, the multiple items form shows test a,b, and c - and templateID updates to be the same for all the results that display.

I need help inserted all displayed records on the form into table: TestRecord.

I can only get the first row to insert with a command button right now.

I'm sorry for the convoluted questions and truly appreciate any help! :) <3
Attached Files
File Type: docx Tests Form Example.docx (52.1 KB, 77 views)
Jul 11 '19 #1
3 913
NeoPa
32,556 Expert Mod 16PB
Let's use your existing code to design a solution as that's likely to be the type of code you're most comfortable with. You'll need to post it of course.

NB. When duplicating data across from one table to another it's important not to de-normalise your database, so we typically copy the index values across rather than the raw data. Does that make sense to you?
Jul 11 '19 #2
NeoPa
32,556 Expert Mod 16PB
PS. Nothing in your attached document is ever likely to be read by anyone here. If you want to post a picture then the facility is available for that. Otherwise the whole of the single question must be included in the forum as text. Any other questions will need to be posted in separate threads. If posted in existing threads then they will be removed.

FYI: I've removed the attachment from your original post. If there's anything in there you feel is necessary for the question then please post as instructed above.
Jul 11 '19 #3
First - I'm extremely grateful for you reviewing my post.

Secondly - I'm a poorly taught amateur so my interpretation of your question is that I should not associate a relationship between the data, but rather input the values via VBA considering my needs? (I'm sorry if incorrect!).

I have attached my DB and the code below needs some tweaking to work correctly...



Expand|Select|Wrap|Line Numbers
  1. Private Sub TestInsert()
  2. Dim numMonths As Integer
  3. Dim intCounter As Integer
  4. Dim strSQL As String
  5.  
  6. numTests = [txtTemplateID_Template]
  7.  
  8. For intCounter = 0 To numTests
  9.   strSQL = "INSERT INTO testrecord ([TemplateID]) VALUES (" & _
  10.             Me![txtTemplateID_Template] & ")"
  11.     CurrentDb.Execute strSQL, dbFailOnError
  12. Next
  13.  
  14. MsgBox (numTests + 1) & " Records have been added to the Table [TestRecords]", _
  15.        vbInformation, "Append Data"
  16.  
  17. End Sub
Attached Files
File Type: zip CoA Template.zip (1.24 MB, 46 views)
Jul 11 '19 #4

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

Similar topics

3
by: Tom Urbanowicz | last post by:
I have a trigger. Each time the triggering event fires, I want to insert some information into another 'audit-like' table (not at all related to the trigger). Some psuedo-code is below as to what...
3
by: mkjets | last post by:
I have worked for hours on trying to find a solution and have not figured it out. I am working in Access 2003. I need to create a query that takes values from 1 table and displays them in...
2
by: jamieda | last post by:
I have a multiple items form displaying the contents of a table. It has a primary key and the records are ordered by this. I want to be able to manually select a record in the form and then...
10
reginaldmerritt
by: reginaldmerritt | last post by:
i wish to change the backcolor of a field on a current record being dispalyed in a 'multiple items' form. However when using me.fieldname01.backcolor = makes refrence to all fields called fieldname01...
1
by: chennaibala | last post by:
hi frds... in my hiden textbox.i have following values... robert|true|true|false|arun|true|false|true|anu|true|true|false| i want to splits in to token and insert in mysql table in following...
1
by: buterfly0707 | last post by:
hi.. i want to add selected multiple items form list box to text box(MultiLine) seperated with a comma in each item.I know how to add multiple list box values to another List box. but how can i...
1
by: loknath11 | last post by:
I have problem with posting multiple items from sel2 to database without selection.It will so kind from you if you could look my code. ///certificate.php <html> <head> <script...
2
by: SCarpenter | last post by:
Hi, I have a subform that opens from a main form via a command button. The main form fields are populated based on a series of queries, ultimately based on tables. The subform is populated from...
3
by: Redbeard | last post by:
I am running Access 2010 and have an understanding of VBA Code, but not much coding experience. I would like to know if there is any way of running a Multiple Items Form off a Stander Form. To...
2
by: nasrin1234 | last post by:
hi tis nasrin, when am creating database(table) using php is successful results came,but i cannot able to insert values to the database using html form, i am using POST method itself,but i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.