Insert A Multiple Selection Into A Table

Mar 23, 2008

This is probably in the wrong forum, but I'm not sure what area the answer would cover, either queries, macros, VBA etc.

I have a form, on which is a listbox with multiple selection enabled getting it's data from a query. What I want to do is for the user to be able to select multiple products from the listbox and have some VBA code or query concatenate each id and insert them into a table, separated by commas so I can separate them again for reports etc.

Eg.

Listbox:
ID
1
2
3

User selects 1 and 2 and clicks submit. Selections are concatenated to 1,2 and inserted into the table.

Please bear in mind I'm not the best at this kind of advanced databasing, so a simple or at least easy to follow answer would be very appreciated.

Thank you all in advance.

Steve

View Replies


ADVERTISEMENT

Help In Insert/update Multiple Selection From A Listbox

Aug 7, 2005

thank you in advance for all your BIG help. :)

I have 3 tables - SMaster, SI_map, ILookup

I need to create a form to Add/Update into SMaster and SI_map tables, which has one-to-many relationship, that's why I use a list box to show the values from SI_map.

in SMaster [ Sid, other fields ]
in SI_map [ primary key, Sid, ILookupid ]
in ILookup [ ILookupid, IName ]

questions:
1. How to get the multi-selected values from the list box?
2. insert these multiple records into SI_map table at the same time with SMaster (if I use the same form to populate all these fields)
3. how to populate the records into form for user to see and update the values?

Any suggestion is appreciated, it is very flexible to change any format such as SMaster and SI_map can be separate forms, as long as it works.

Thank you.

View 3 Replies View Related

Modules & VBA :: Parent Table Revision History - Insert Multiple Records Into Child Table

Sep 8, 2014

I have a parent table (tblLabels) and a child table (tblRevision) where the revision history for the parent table is kept.

The parent table is populated via an excel import and may have several records imported at once. Instead of having the user manually enter a new record note in the child table for each record imported into the parent table, I've created a form that collects the necessary data (date, person who added the record, person who authorized the record, and notes) and then creates a revision history for each new record.

This is what I have so far:

Code:

Private Sub cmdAddNotes_Click()
Dim strSQL As String
Dim RevisionDate As String
Dim RevisionRevisedBy As String
Dim RevisionDesc As String

[Code] ....

When I run the code nothing happens. No error, no new records create, etc. My suspicion is that I may need to use an INSERT INTO query instead of an UPDATE query, but I'm not sure how to go about matching up the foreign keys if that's the case.

View 14 Replies View Related

Forms :: Multiple Selection Listbox To Table

Jul 24, 2013

I have a form called "Record Call" when a user can input the calls that they have made or are scheduled. This form is based on the table "Call Records". I have created a new table called "CallAttendees" and added a listbox to my form for users to select who attended/participated in the call.

My code loops through the selections and writes these selections to the "CallAttendees" table. In this table i have an auto #, CallRecord, and Attendee fields. My code is supposed to write the "ID" field from the "Call Record" table to the "CallAttendees" table so that i can create the relationship between the two tables. However, this field is coming up blank since my form isn't generating the auto # until the record is closed.The tables are stored in a SQL server. I also tried saving the record prior to running my code.

View 5 Replies View Related

Forms :: Multiple Selection For Pivot Table

May 2, 2013

I am working on a form (UI). Initially I have used a combo box, where you can pick an option and the rest of the form will display only data related to the option/record. My form contains different subform, and most of them are PivotChart form as subform, and also some table with the text box that will display the data according the selection from the combox box or form control.

I would like to know if there is any way beside the combox box, that will allow me to do multiple select. For example in excel, for pivot table, we can do multiple selection and automatically, the pivot table will show the total (let say sum) of the selected option.

Again, my form has pivot chart form as subform, and label with text.

Also, I have a form that is only have pivot chart as subforms.

View 3 Replies View Related

Queries :: Insert Multiple Groups Of Text Fields In Table

Feb 17, 2015

I am trying to do is to make a for loop to insert multiple text fields in on table.

Depending on the counter (Zaehler) it should insert that representing text field. for example if Zeahler is 1 it should input whatever is inside the text field KVP_Kfm1 if its 2 then it should input the textfield KVP_Kfm2 and so on. here is the code that I'm trying to work but sadly it wont.I believe that the mistake is that my syntax is wrong but i cant figure out what is right.

Code:
For Zaehler = 0 To (Forms!frmCMP!txtAuslaufjahr - Forms!frmCMP!txtAnlaufjahr)
SQL = "INSERT INTO tblLifecycle_Projektion(ID_Berichtstand, KVP_Kfm, KV P_technisch, AeJ, MoPf, skAe, MiBst, Sonstige_Effekte, " & _
"KVP_technisch_FTR, KVP_Kfm_FTR, AeJ_FTR, MoPf_FTR, sk Ae_FTR, Sonstige_Effekte_FTR, Jahr) VALUES " & _

[Code] ....

View 3 Replies View Related

Insert Relevant Value Based On Selection

Jun 15, 2005

I have a form with a combo box this combo box looks up values in my STC table. The STC table has two fields STC & Resolver and each STC has a unique associated Resolver. What i want to happen is after the user has selected the STC from the combo box on the form the associated Resolver be displayed in a textbox on the form. I am ussing the following code but nothing seems to be happening:

Private Sub cboSTC_AfterUpdate()
Dim ResolverSource As String

ResolverSource = "SELECT tblSTC.[Resolver] " & _
"FROM tblSTC " & _
"WHERE tblSTC.[STC]='" & Me.cboSTC.Value & "';"

Me.txtResolver.RowSource = AgentSource
Me.txtResolver.Requery


End Sub

View 1 Replies View Related

Forms :: Insert / Select Values From Selection Combo Box

May 20, 2013

I want to insert obtain marks of the subjects. Find the attached my db. when i select combo value my requirement is to insert the all records which associate with the combo. but when i select combo value it will happen nothing.

View 7 Replies View Related

Tables :: Use Insert Into Command To Insert Filepath Into Table That Adds Blank Label

Aug 28, 2014

I am at work, and I have acquired a database that prints labels. They now want the database to be coded so that after certain labels are printed the database will print a blank label. I have the code figured out as a Do While statement in order to print the blank label. The problem I am having is that I am trying to use the Insert Into command to insert the filepath into the table that adds the blank label.

|DoCmd.RunSQL "INSERT INTO Rod_tmakLabels ( Print, [Order] ) SELECT Yes AS Expr1, 'Rods Labels' AS Expr2"|

If I run the above command, it just adds the text "Rods Labels" at the end of the table. Is there anyway with the INSERT INTO command that I can insert the new label between the 2nd and 3rd row and add another row? Or is the command designed only to add a new row to the end? I haven't had any luck searching for this yet.

View 1 Replies View Related

Multiple Selection Of Records

Dec 17, 2005

I'm building a database for a realtor friend. Part of his job is keeping track of where his clients want to live. I have added a field named "Areas". I need to populate that field with names of cities where his clients want to buy thier house. Sometimes there are only a couple of cities. Other times there could be more then 10. I don't want him to type these cities in. He is not a good typer, either am I, and he is prone to abbreviations and typos. Garbage in garbage out. I would like to provide him a drop down list, or something like that, of all the cities or areas and have him select each area and then either hit a command button or copy/paste it to that text box. Either way will work. The command button would be nifty. The result would give him the option of doing a form filter and being able to filter that text box for ex: "atlanta" and "syracuse". He then could cue these people when he has a property come available in either one of those cities.

I DON'T understand VBA code. I don't know how to write it or where to put it.

I tried to search this site and I could not find any threads like this, to my amazement. If there is a similiar post out there and I could not find it I apologize in advance.

View 1 Replies View Related

Multiple Selection In A Combo Box

Oct 17, 2006

In form "sendmail" their is a combobox "to" which gets ur email address.
i want we could be able to select multiple entries thruogh this combo box and it should be seprated by a semi colon

View 2 Replies View Related

Multiple Selection In Listbox

Jul 28, 2006

Hi

In my application, I am allowing multiple selection in a listbox.
The data is saved in table. While retrieving, the items that were selected for saving, show as selected. But on printing ListIndex, it prints -1. What could be wrong ? I need to resolve it. Any solution ?

View 1 Replies View Related

Multiple Selection In A Combo Box

Oct 17, 2006

In form "sendmail" their is a combobox "to" which gets ur email address.
i want we could be able to select multiple entries thruogh this combo box and it should be seprated by a semi colon

View 2 Replies View Related

Multiple INSERT String

Aug 4, 2005

Can anyone help?

Have searched the net with no luck. This is my problem.

I am trying to use a multiple INSERT string to create records in a table, from a VB application and using ADO to do it.

If I send the single INSERT it works fine, but if I try to send more than one in the same string I get a 'MISSING SEMI COLON AT END OF STATEMENT' error.

I have tried putting one at the end of each statement, then just at the end of the INSERT statements string, but still get this error.

Can Access actually handle more than one SQL instruction at a time?

Thanks for any help.

View 3 Replies View Related

Trying To Insert Multiple Rows

Nov 13, 2006

I'm trying to insert multiple rows into a table at once, but I'm having problems.

I've tried a syntax like this:

INSERT INTO [TABLE] ( [FIELD1], [FIELD2], [FIELD3] ) VALUES
(( '1', 'A', '1' ),( '2', 'B', '2' ));

..but with no success.


On a site I even found this other way, but with no success either...

INSERT INTO [TABLE]
SELECT '1', 'A', '1'
UNION ALL
SELECT '2', 'B', '2';

Is it possible to insert multiple rows and I'm just missing the syntax, or is it not possible with Access?

View 1 Replies View Related

INSERT: Multiple Subqueris

Jan 25, 2007

I have a form with a print button. When pressed it runs of a set of labels between 2 dates. I wish to keep a log of the print jobs that are done. Storing the date and time that the print was done, who did it and (The bit I can't figure) the date range of the print job.

I am trying to make an INSERT statement with 2 queries. 1 for the oldest date of the print and one with the most recent date.


INSERT INTO PrintHistory (RangeStart, RangeEnd)
VALUES (
(SELECT TOP 1 [Bookings].DateEntered
FROM [Bookings]
WHERE [Bookings].ConfirmationSent Is Null
ORDER BY [Bookings].DateEntered),

(SELECT TOP 1 [Bookings].DateEntered
FROM [Bookings]
WHERE [Bookings].ConfirmationSent Is Null
ORDER BY [Bookings].DateEntered DESC)
);


The above doesent work and gives 'Reserved Error (-3025)'

Am I barking up the wrong tree with this or have I just made a small error?

View 1 Replies View Related

Multiple Insert Into - Some Don't Work

Nov 7, 2007

I have an empty database, copies of which will be used in a number of locations. Before a copy is sent out to the user some data, specific to the user's location, needs to be entered into a total of 40+ tables . I have tried to do this using a series of Update and Insert queries but find that not all of the changes have been successful.
It seems as if a block of several tables is missed every so often through the list, as if Access has had trouble doing the writes quickly enough and skipped some.
I have looked for some method of forcing each query to complete its writes before moving on to the next one, but have found nothing so far.
The database is self-contained and will be run on a PC, not on a server.
What I am looking for I guess is the Access equivalent to the Commit command used in other systems.

Will someone please tell me, is there anything like this In Access 2000?

View 1 Replies View Related

Insert Multiple Records

Oct 11, 2005

I am working on an electronic catalog for my company. I am populating the database and I'm trying to speed the process. This is what I want to do. This database deals with cars and trucks, I would like to design a form where I can enter:

1989-1995 Chevy Malibu, etc.

Once the form is full and I save the records it will create 7 individual records, one for each year.

1989 Chevy Malibu
1990 Chevy Malibu and so on.

Any ideas?

View 4 Replies View Related

Insert Multiple Rows

Nov 6, 2006

I am trying to insert multiple rows to a table using the query

insert into rvp (rvp, rvp_name, controller_id)
values (1200, 'rvp1', 10), (1201, 'rvp2', 10)

But I am getting an error "Missing semicolon( at the end of SQL statement" and placing a semicolon at the end isn't helping either. I can insert a single row so column type or primary key isn't a problem.

Here's the table structure,

rvp - number (pk)
rvp_name - text
controller_id - number

Can someone please help me out.

View 3 Replies View Related

Multiple Selection In A Query From A Form

Aug 1, 2006

Dear All

I've got an issue with a query/form combination that I'm working on. I have the following:

A query where one of the the fields is 'Name' (a text field). 'Name' can be one of 6 different values. I have a form which has 6 check boxes, one for each name. I'm using check boxes on the form rather than a multiple selection list box simply because I think it looks better.

When the user has checked one or more of the check boxes and hits the 'show results' button, I want the query to open up with the details for orders associated with the name(s) selected.

I am writing my query in 'design view' rather than in 'SQL view', and don't know what to put in the criteria box of the 'Name' field. Depending on which check boxes are checked, I'm building a string and storing it in a text box, called Text1. I think the best way to do the filter is to use the In operator, and I currently have a structure like this in the criteria of the query: In([Forms]![Form1]![Text1]). This, however, doesn't give any results.

The problem I have, therefore, is that I don't know the correct syntax for the text within Text1. If I have, for example "Rob","Dave" as the text in Text1, it doesn't work, but if I put In("Rob","Dave") in the criteria rather than referencing the text box, it works fine.

Do anyone know what I'm doing wrong?

View 1 Replies View Related

Query By Multiple Selection List Box

Jul 24, 2007

so i have two listboxes that have the values i want for the query parameters. I slightly modified one code i found so that i can query using one of them, however i cannot figure out how to get the second listbox to put criteria into another field. The working code i'm using is:

Private Sub Command_Click()
On Error GoTo Err_Command_Click

On Error GoTo Err_Handler
Dim varItem As Variant
Dim strCriteria As String
Dim strSQL As String


For Each varItem In Me.PartyBox.ItemsSelected
strCriteria = strCriteria & "counterparties.counterparty =" & Chr(34) & Me.PartyBox.ItemData(varItem) & Chr(34) & " Or "
Next varItem


strCriteria = Left(strCriteria, Len(strCriteria) - 4)

strSQL = "SELECT counterparties.[Counterparty Entity], Fund.[Fund Name], products.Product, combine.[Available?] " & _
"FROM products INNER JOIN (Fund INNER JOIN (counterparties INNER JOIN combine ON counterparties.[Counterparty ID] = combine.[company id]) ON Fund.[Fund ID] = combine.[fund id]) ON products.[Product ID] = combine.[product id] " & _
"WHERE " & strCriteria


CurrentDb.QueryDefs("1").SQL = strSQL


DoCmd.OpenQuery "1"

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number = 5 Then
MsgBox "Must Make A Selection First", , "Make A Selection First"
Exit Sub
Else
MsgBox Err.Number & " " & Err.Description
Resume Exit_Handler
End If


Dim stDocName As String
stDocName = "combqry"
DoCmd.OpenQuery stDocName, acNormal, acEdit

Exit_Command_Click:
Exit Sub

Err_Command_Click:
MsgBox Err.Description
Resume Exit_Command_Click

End Sub



I am trying to be able to search by Product and counterparty.
Any help is greatly appreciated, thanks!

View 8 Replies View Related

NewBaby:Multiple Selection In ListBox!

Dec 15, 2005

I am designing a small database.
I have problem in selecting Mutiple list values from list box.

I have a table of Personal.With fields
SrNo ------------- autonumber
Name -------------- Text
Age ---------- Number
Interset ------------ (Text)
//In Interset Properties through lookup tag I have
Display Control -------ListBox
Row Source Type --------- Value List
Row Source ---------------- "Swimming","Football","Cricket",hockey"

When I made form I got all the List Box Items. For single Selection it has worked. But If I want Multiple selection. I changed the property List Box property Multi Select from "None" to Simple. Now It worked with Multiple Selection.But If one first record I select Swimming, Football.On second record it would be blank. And select my self. But the previous one is saved on all the next records.If two selction on first next all same selction with 2.
If three then three.

I want Individual selection. It must be saved.According to corresponding record.

Facillitate in this regard is much appreciated.

View 6 Replies View Related

Multiple Input Mask Selection

Jan 1, 2006

I’am a fairly new to access I have a Database with forms, on one form that is linked to the student table you can put in all the student details.
what I want to do for the post code is have a drop down box with two place names that have different formats for there post codes E.G London : LL0 0LL and Cardiff : LL00 0LL , depending on which one is selected the corresponding mask would be applied to the Post Code text box.
Any Suggestions will be much appreciated.

View 4 Replies View Related

Queries :: Multiple Records Selection

Jun 13, 2014

I have a database that contains different departments per office location with the dept. codes such as 100, 101, 102, 103 etc.

I like to have a criteria in a query that will give me all departments that are running from one office location OR if I do not want one dept. to show in my query to be excluded.

Also, the way I currently set the parameters is, it is asking for the office location by state, county, city, address and department code. I set the department criteria as Not [Department] which excludes the dept. that I do not want to see in the query, BUT I also want to have an option that when I run the query to SEE all the departments.

Is it possible to have a criteria like that?

View 3 Replies View Related

Insert Multiple Blank Records

Apr 26, 2006

Hi,

I'm new to Access and I've run into a little problem. I've created a table with a primary key (autonumber) which will contain 1520 records. At present I only have data for the last 8 records. Ideally I would like to create 1512 blank records, with only the autonumber entered e.g. 0001, 0002, 0003 etc.

Unfortunately I cant add the data that I have got to 0001 - 0008 as it relates specifically to the primary ID.

Thanks.

View 10 Replies View Related

Insert Multiple Values Into A Text Box

Apr 9, 2007

Hi All

I have a list box. Below it lies a text box.

I'd like to click on multiple values in the list box which then populates a text box with each value to form a sentence.

currently my code looks like this

Dim Comment As String
Comment = Me.lstComments.Column(0)
Me.txtComment = Comment

Using the above method only inserts one value. How can I modify this to insert multiple values into the text box?

Much appreciated

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved